重写Apache的URL

重写Apache的URL,apache,.htaccess,mod-rewrite,Apache,.htaccess,Mod Rewrite,我试图重写Apache配置文件上的链接,使其看起来像内部链接,但实际上是外部链接 我的站点上的链接看起来像这样,并且有多个查询字符串 http://www.mysite.com/myscript.asp?somevar=1&othervar=2 但单击时将被改写为: http://www.othersite.com/script.asp?somevar=1&othervar=2 以下是我目前的情况(不工作): 有人能让这条规则生效吗?谢谢 我希望这会有所帮助: Rewrite

我试图重写Apache配置文件上的链接,使其看起来像内部链接,但实际上是外部链接

我的站点上的链接看起来像这样,并且有多个查询字符串

http://www.mysite.com/myscript.asp?somevar=1&othervar=2
但单击时将被改写为:

http://www.othersite.com/script.asp?somevar=1&othervar=2
以下是我目前的情况(不工作):


有人能让这条规则生效吗?谢谢

我希望这会有所帮助:

RewriteRule ^myscript\.asp\?(.*)$ http://www.othersite.com/script.asp?$1 [L]

注意:问号(?)和点(.)在正则表达式中有特殊意义,因此如果您想将它们用作无意义字符请将
\
放在它们前面

嘿,谢谢你的回答。我忘了避开角色-谢谢!但是,我仍然无法让更新后的代码正常工作-有什么想法吗?@Matt当转到script.aspHey,script.asp是外部网站时会发生什么,所以它就去了那里。我通过在.htaccess上使用重定向解决了这个问题,如下所示:
RewriteRule^(.*)$http://www.othersite.com/script.asp?$1[L,R=302]
我把它放在自己的文件夹
/myscript/
中,并在我的网站上使用了以下url:
http://www.mysite.com/myscript/somevar=1&othervar=2
。这项工作非常好,做得很好-谢谢你的帮助。
RewriteRule ^myscript\.asp\?(.*)$ http://www.othersite.com/script.asp?$1 [L]