重定向的URL(具体GET参数) [英] Redirecting URLs (with specific GET parameters)

查看:410
本文介绍了重定向的URL(具体GET参数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个已被取代由另一个链接这个古老的调查链接,所以基本上我希望任何人试图访问的网址:

I have this old survey link that is has been superseded by another link, so basically I want anyone trying to access the URL:

http://mywebsite.com/survey/view_survey.php?surveyID=1

要被重定向到:

http://mywebsite.com/survey/view_survey.php?surveyID=2

我能做到这一点在Apache配置或htaccess文件?

Can I do this in the Apache configuration or htaccess file?

我想在我的httpd.conf文件的重定向部分以下规则:

I tried the following rule in the Redirect section of my httpd.conf file:

Redirect 301 /survey/view_survey.php?surveyID=1 http://mywebsite.com/survey/view_survey.php?surveyID=2

但它不工作。我怀疑在处理规则时的GET参数不被使用。

But it doesn't work. I am suspecting that the GET parameters are not used when processing the rule.

是我砍我的code在特定surveyID重定向唯一的选择?

Is my only option to hack my code to redirect on a specific surveyID?


随着使用重写规则的建议,我想在我的.htaccess文件如下:

Following the suggestion of using the Rewrite rules, I tried the following in my .htaccess file:

RewriteRule ^survey/view_survey\.php\?surveyID=1525$ /survey/view_survey.php?sur
veyID=1607

但是,这并不工作。我有重写引擎启动和运行,因为我还有一个重写规则目前正在运行。

But that doesn't work. I do have the rewrite engine up and running, because I have another rewrite rule currently running.

推荐答案

试试这个在.htaccess文件:

Try this in a .htaccess file:

RewriteEngine on
RewriteCond %{QUERY_STRING} (^|.*&)surveyID=1525(&.*|$)
RewriteRule ^survey/view_survey\.php$ /survey/view_survey.php?%1surveyID=1607%2 [L,R=301]

这篇关于重定向的URL(具体GET参数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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