XAMPP mod_rewrite 找不到对象错误

XAMPP mod_rewrite object not found error

我想从

创建友好的 url

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= [QSA,L,NE]

categories.php

<?php 
echo $_GET["cat"]; 
?>

测试 https://htaccess.madewithlove.be/

输出url:http://localhost/shop/categories.php?cat=asd(这个url有效)

文件夹商店中我只有 2 个文件:

路径:

C:\xampp\htdocs\shop

文件:

更多信息:

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

您的 /shop/.htaccess 文件应如下所示:

Options -MultiViews

RewriteEngine On
RewriteBase /shop/

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