开发者

.htaccess 301 redirect without GET var

开发者 https://www.devze.com 2022-12-23 16:15 出处:网络
For a website I\'m currently working on we\'re redirecting our old URL\'s permanently to new ones like this:

For a website I'm currently working on we're redirecting our old URL's permanently to new ones like this: Redirect 301 /oldfile.php http://www.site.com/show/newurl

Now I come across this situation in which the old url has 开发者_运维技巧a get var like: Redirect 301 /oldfile.php?var=name http://www.site.com/show/newurl

This will redirect the oldfile to the new url plus it adds the get var so it redirects to: http://www.site.com/show/newurl?var=name

How would I set up this redirect without the get var?


mod_rewrite can strip off the query string:

RewriteEngine on
RewriteRule ^/?oldfile.php$ http://www.site.com/show/newurl? [R=301,L]
0

精彩评论

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