的.htaccess 301重定向没有GET变种 [英] .htaccess 301 redirect without GET var

查看:246
本文介绍了的.htaccess 301重定向没有GET变种的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一个网站,我目前正在对我们重定向我们的旧的URL的永久换新这样的: 重定向301 /oldfile.php http://www.site.com/show/newurl

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

现在我遇到这种情况,即旧的URL有一个GET变种,如: 重定向301 /oldfile.php?var=name 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

这将重定向的oldfile新的URL再加上它增加了获取无功,因此重定向到: http://www.site.com/show/newurl?var=name

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

我将如何设立这个重定向没有获取VAR?

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

推荐答案

的mod_rewrite 可以去掉查询字符串:

mod_rewrite can strip off the query string:

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

这篇关于的.htaccess 301重定向没有GET变种的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆