开发者

htaccess add 301 moved permanently to RewriteRule

I have this rule in my .htaccess file:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . /index.php

what it does is to redirect all url's index.php?somevar=# to index.php, however when it redirect's sends out code 302 and i want it to be 301.

I tried to add [R=301] after RewriteRule . /index.php but it doesn't work.

Some help is appreciated开发者_如何学Go :-)


This thing does not do what you describe. Your rule sends every request to non-existent files to index.php. The URL:

index.php?anything

already calls index.php. You don't need any rewrite magic to handle that.

Also ...

RewriteRule . /index.php

is a bad practice. It does not cause you problems now, but it could in the future, when you modify the rules. You'd rather use:

RewriteRule .* /index.php
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜