我在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/ 我明白了:
请帮忙,谢谢
答案 0 :(得分:1)
在/myproject/.htaccess
中使用此代码:
RewriteEngine On
RewriteBase /myproject/
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?request=$1 [QSA,L]
RewriteRule
之后不应该有正斜杠。
答案 1 :(得分:0)
你真的不必那么复杂。
这应该足够了:
RewriteEngine On
RewriteBase /myproject/
RewriteRule ^/(.+) /myproject/index.php?request=$1 [L]
我强烈建议您阅读有关htaccess的更多信息。即使它看起来像它也不是那么复杂。