【发布时间】:2015-02-25 15:23:38
【问题描述】:
我对 php 的重写规则有疑问,我希望它是:
localhost/myproject/XXXX => localhost/myproject/index.php?request=XXXX
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule /(.*)$ index.php?request=$1 [QSA,NC,L]
</IfModule>
我在 apache 上激活了 mod_rewrite,我的 index.php 在 WAMPDIR\www\MyProject 下
当我在这里测试时:http://htaccess.madewithlove.be/ 我明白了:
请帮忙,谢谢
【问题讨论】:
-
.htaccess 与 index.php (WAMPDIR\www\MyProject) 位于同一文件夹中,当我在浏览器上测试它或使用 Postman 时,我得到一个未找到的错误:
The requested URL /myproject/xxx was not found on this server. -
显示500内部错误,所以文件没有问题,我认为问题来自规则。
-
localhost/myproject/index.php?request=XXXX工作正常,但我想以这种方式访问它:localhost/myproject/XXXX通过重写 url
标签: php apache .htaccess mod-rewrite url-rewriting