我有一个已被取代由另一个链接这个古老的调查链接,所以基本上我希望任何人试图访问的网址:
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参数)
发布评论