重定向的URL(具体GET参数)

编程入门 行业动态 更新时间:2024-10-22 20:27:53
本文介绍了重定向的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:

mywebsite/survey/view_survey.php?surveyID=1

要被重定向到:

mywebsite/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 mywebsite/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参数)

本文发布于:2023-11-01 11:46:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549258.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   参数   URL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!