我的.htaccess文件中有这条规则:
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php
它的作用是将所有url的index.php?somevar =#重定向到index.php,但是当它重定向时发送代码302并且我希望它是301。
我尝试在[R=301]
之后添加RewriteRule . /index.php
,但它不起作用。
赞赏一些帮助: - )
答案 0 :(得分:2)
这件事不符合你的描述。您的规则会将对不存在的文件的每个请求发送到index.php
。网址:
index.php?anything
已拨打index.php
。你不需要任何重写魔法来处理它。
另外......
RewriteRule . /index.php
是一种不好的做法。它现在不会给您带来问题,但将来可能会在您修改规则时出现问题。你宁愿使用:
RewriteRule .* /index.php