2012-11-07 82 views
0

我有一个redirect.php和一个链接,它不起作用在WORDPRESS。mod_rewrite外部链接问题(wordpress)

我希望当我点击我的网站“你好”的链接,它进入redirect.php,用户看到5秒的微调,以及用户退出我的网站hello.com

它看起来像我的mod_rewrite有问题,我无法解决

我真的很感激一个非常详细的答案。我很初级

这就是我所拥有的。

1 .-我有我的主页外部链接:

<a href="http://redirect.php?link=hello.com">Hello</a> 

2:在redirect.php,我有:

<html> 
<head> 
    ... 
    <meta http-equiv="refresh" content="5;url=<?php echo $_GET['link'];?>" /> 
    ... 
</head> 
<body> 
    <h1>You are leaving my site!</h1> 
    <img src="/images/spinner.gif" alt="spinner" /> 
</body> 
</html> 

回答

0

链接<a href="http://redirect.php?...不正确。这应该很可能是<a href="/redirect.php?...或您的服务器上的任何子目录。

您还应该在您的链接参数中包含该协议或将其预先添加到您的元标记中。另外,请确保HTML代码对您的元标记中的链接进行编码,并在链接参数中对域名进行正确的URL编码。如果你在你的网站的根目录下的文件redirect.php

<a href="/redirect.php?link=http%3A%2F%2Ftest.com">Hello</a> 

所以,改变链接。和meta标签更改为:

<meta http-equiv="refresh" content="5;url=<?php echo htmlentities($_GET['link'], ENT_QUOTES,);?>" /> 

,你可能想要做链接参数的有效性一些验证,你可能还需要检查引荐URL($_SERVER('HTTP_REFERER')),以确保您只为执行重定向从您自己的网站链接(即不要创建open redirect漏洞)。