Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP重定向到URL中的链接_Php_.htaccess_Redirect - Fatal编程技术网

PHP重定向到URL中的链接

PHP重定向到URL中的链接,php,.htaccess,redirect,Php,.htaccess,Redirect,对于我的会员链接,我希望它们通过中间页面(称为路由器)重定向,以测量某些数据和效率 假设我的会员链接为www.affiliate.in?id=sdff¶=dshjgsf&aaffid=JAHAJEE 还有一个中间页面www.mysite.com/redirect.php?someid=1&otherid=2&url=THE_url\u TO_redirect\u TO 我的问题是附属链接有?和&,因此当我在这个路由器URL中使用附属链接时,我无法获得完整的$\u get[URL]!关于如

对于我的会员链接,我希望它们通过中间页面(称为路由器)重定向,以测量某些数据和效率

假设我的会员链接为
www.affiliate.in?id=sdff¶=dshjgsf&aaffid=JAHAJEE
还有一个中间页面
www.mysite.com/redirect.php?someid=1&otherid=2&url=THE_url\u TO_redirect\u TO


我的问题是附属链接有
&
,因此当我在这个路由器URL中使用附属链接时,我无法获得完整的
$\u get[URL]
!关于如何完整处理这些附加参数的任何帮助?

您可以通过

$_SERVER['QUERY_STRING']

对Url进行编码

string urlencode ( string $str )
当对URL的查询部分中使用的字符串进行编码时,此函数非常方便,可以方便地将变量传递到下一页

将\u URL \u传递到\u重定向\u到函数

作为


对url进行编码并使用它(


此urlencode对所有特殊字符进行加密

如果您想使用htacces获取url,请使用以下链接。这将指引你很多

<?php 
$afurl = urlencode('http://www.affiliate.in?id=sdff&para=dshjgsf&aaffid=JAHAJEE');
$url = 'http://www.yourdomain.com/redirect.php?someid=1&otherid=2&url='.$afurl;
echo $url;
?>

主要的问题是,我认为您得到的URL是这种格式的
[a-zA-Z0-9 |]
您需要将其更改为
(.*)

,使用
{QUERY\u STRING}
for
htaccess
。阅读文档
urlencode
/
rawurlencode
@jahajee.com显示您的htaccess代码
<?php 
$afurl = urlencode('http://www.affiliate.in?id=sdff&para=dshjgsf&aaffid=JAHAJEE');
$url = 'http://www.yourdomain.com/redirect.php?someid=1&otherid=2&url='.$afurl;
echo $url;
?>