XAMPP mod_rewrite对象未找到错误

时间:2018-07-10 11:22:27

标签: .htaccess mod-rewrite xampp

我想从

创建友好的网址

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

文件:

  • .htaccess
  • categories.php

更多信息:

  • 已加载mod_rewrite(已在phpinfo和httpd.conf中检入)
  • AllowOverride httpd.conf和httpd.xampp.conf中的所有内容

1 个答案:

答案 0 :(得分:1)

您应该禁用MultiViews选项,该选项在大多数情况下都是默认启用的(请参阅本主题的this post and my answer

您的/shop/.htaccess文件的外观如下:

Options -MultiViews

RewriteEngine On
RewriteBase /shop/

RewriteRule ^category/([^/]+)$ categories.php?cat=$1 [L,NE]