我想从
创建友好的网址http://localhost/shop/categories.php?cat=asd-> http://localhost/shop/category/asd
但是我总是从Apache收到Object not found
错误404错误。
.htaccess:
RewriteEngine On
RewriteRule ^.+category/([a-zA-Z]+)$ /shop/categories.php?cat=$1 [QSA,L,NE]
categories.php
<?php
echo $_GET["cat"];
?>
经过https://htaccess.madewithlove.be/
的测试输出网址:http://localhost/shop/categories.php?cat=asd(此网址有效)
文件夹商店中我只有2个文件:
路径:
C:\ xampp \ htdocs \ shop
文件:
更多信息:
答案 0 :(得分:1)
您应该禁用MultiViews
选项,该选项在大多数情况下都是默认启用的(请参阅本主题的this post and my answer)
您的/shop/.htaccess
文件的外观如下:
Options -MultiViews
RewriteEngine On
RewriteBase /shop/
RewriteRule ^category/([^/]+)$ categories.php?cat=$1 [L,NE]