[英].htaccess: Want query string added to 301 Redirect to same url
Example: When someone visits this URL 示例:当有人访问此URL时
http://example.com/site/register http://example.com/site/register
I'd like this query string to be automatically added: 我希望自动添加以下查询字符串:
http://example.com/site/register?destination=thankyou http://example.com/site/register?destination=thankyou
I've tried the following in my .htaccess file: 我在.htaccess文件中尝试了以下操作:
Redirect 301 /site/register /site/register?destination=thankyou 重定向301 / site / register / site / register?destination = thankyou
But this creates an infinite redirect loop. 但这会创建一个无限的重定向循环。
I've crawled the web for hours for a solution but to no avail. 我已经在网上搜寻了数小时,但没有解决办法。 Thanks in advance.
提前致谢。
if register
is PHP, use something like: 如果
register
是PHP,请使用类似以下内容的代码:
<?php
if(!array_key_exists('destination',$_GET))
header('Location: '.http_build_query(
array_merge($_GET,array('destination'=>'thankyou')));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.