[英]Localhost htaccess not working
我有以下.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错误)。
我不想将.htaccess移至根目录,因为在其他项目中可能会使用其他.htaccess。
是的,在httpd.conf中将AllowOverride设置为All。
尝试将其添加到httpd.conf <Directory /Applications/XAAM/htdocs/coffee_shop>AllowOverride All</Directory>
但是没有用。
有什么建议么?
谢谢。
在我看来,您似乎缺少重写规则的“ html”部分-在url中引用了它,但没有在规则中引用-因此是404
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /coffee_shop/
# For sales:
RewriteRule ^html/shop/sales/?$ sales.php
# For the primary categories:
RewriteRule ^html/shop/(coffee|goodies)(/?)$ shop.php?type=$1
# For specific products:
RewriteRule ^html/browse/(coffee|goodies)/([0-9]+)(/?)$ browse.php?type=$1&id=$2
# For shop:
RewriteRule ^html/shop/([A-Za-z\+]+)(/?)$ shop.php?type=$1
</IfModule>
http://localhost/coffee_shop/html/shop?type=goodies can be accessed via http://localhost/coffee_shop/html/shop/goodies
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.