【发布时间】:2015-10-15 23:07:34
【问题描述】:
我有以下不工作的 .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /coffee_shop/
# For sales:
RewriteRule ^shop/sales/?$ sales.php
# For the primary categories:
RewriteRule ^shop/(coffee|goodies)/?$ /shop.php?type=$1
# For specific products:
RewriteRule ^browse/(coffee|goodies)/([A-Za-z\+\-]+)/([0-9]+)/?$ browse.php??type=$1&category=$2&id=$3
# For shop:
RewriteRule ^shop/([A-Za-z\+]+)/?$ shop.php?type=$1
</IfModule>
当我访问 http://localhost/coffee_shop/html/shop/goodies 时应该被翻译成 http://localhost/coffee_shop/html/shop?type=goodies 但事实并非如此。我收到 404 Object Not Found 错误,因此正在读取文件(我在其中放入了一些垃圾代码并导致 500 错误)。
- 文件夹结构为:
- htdocs/ -项目1/ -项目2/ -咖啡店/
我不想将 .htaccess 移至根目录,因为我可能会在其他项目中使用不同的 .htaccess。
是,AllowOverride 在 httpd.conf 中设置为 All
尝试添加到 httpd.conf
<Directory /Applications/XAAM/htdocs/coffee_shop>AllowOverride All</Directory>,但没有成功。
有什么建议吗?
谢谢。
【问题讨论】:
-
你在htaccess规则之后列出的url在路径中包含html,但重写规则中没有引用这些url
标签: php apache .htaccess mod-rewrite