不支持 htaccess 重写规则变量

htaccess rewrite rule variable is not supported

我对 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= [QSA,NC,L]
</IfModule>

我在 apache 上激活了 mod_rewrite,我的 index.php 在 WAMPDIR\www\MyProject

当我在这里测试时:http://htaccess.madewithlove.be/ 我明白了:

请帮忙,谢谢

你真的不必把它搞得那么复杂。

这应该足够了:

RewriteEngine On
RewriteBase /myproject/
RewriteRule ^/(.+) /myproject/index.php?request= [L]

我强烈建议您阅读有关 htaccess 的更多信息。它真的没有那么复杂,即使它看起来像它。

/myproject/.htaccess中有此代码:

RewriteEngine On
RewriteBase /myproject/

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php?request= [QSA,L]

RewriteRule 之后不应有前导斜线。