嘿,我是一个有htaccess的新手。在我的站点(mysite.com)上,我获得了一个链接,该链接可以将变量定向到安全站点(othersite.com/somepage.php?urlink='www.mysite.com').上的页面并将其发送到该页面
如何编辑我的htaccess文件以将othersite.com/somepage.php?urlink='www.mysite.com‘重写为urlink具有的任何值。
我的htaccess里有这个
Options +FollowSymlinks<br>
Options All -Indexes<br>
Options Indexes Includes FollowSymLinks ExecCGI
RewriteEngine on
RewriteRule ^&urlink=(.*) http://$1 [P]发布于 2011-08-18 21:37:33
好奇心。如果您在其他服务器上请求一个页面,您自己的htaccess将不会为您提供解决方案。(如果你自己有权限/拥有othersite.com,他们的htaccess可以做到这一点)。
相反,我会使用HTTP_HEADER编写一个小的PHP文件重定向到otherside.com。因此,您可以告诉htaccess隐藏您的php-Url。
我对你的问题理解正确了吗?
<?php
$myInputURL = $my_POSTURL;
$myOtherSite = "http://www.otherside.com?urllink=";
$myURL = $myOtherSite . $myInputURL;
header("Location: ".$myURL);
?> 发布于 2011-08-18 22:00:31
RewriteRule不能像那样直接处理查询字符串。
例如,如果URL为http://www.example.com/kitten.php?say=meow,则RewriteRule只能与kitten.php部分匹配。其他所有内容都可以通过RewriteCond进行匹配,例如:RewriteCond %{QUERY_STRING} ^urlink=(.*)。
请参阅文档:http://httpd.apache.org/docs/current/mod/mod_rewrite.html#rewritecond
在您的情况下,它可以是这样的(对不起,我不知道您到底想要实现什么,因此我只是编辑您现有的规则):
Options Indexes Includes FollowSymLinks ExecCGI
RewriteEngine on
RewriteCond %{QUERY_STRING} ^urlink=(.+)$
RewriteRule ^somepage\.php$ http://%1 [P]https://stackoverflow.com/questions/7108140
复制相似问题