我需要在apache处代理请求,以防requeset为/ anotherserver而来,并且具有名称之类的查询参数。
因此传入的URL将是......
mywebsite.com正在运行apache。 http://mywebsite.com/anotherserver/admin/mypage.aspx?name=<>
它应该代理它在IIS服务器上运行门户。 HTTP://<> -mywebsite.com/admin/mypage.aspx
我正在编写我的规则
RewriteCond %{REQUEST_URI} ^/anotherserver.* [NC]
RewriteCond %{QUERY_STRING} ^name=([^&]+)
RewriteRule ^anotherserver/(.*)$ http://%1-mywebsite.com/$1 [NC,P,L]
此规则未运行,很好。这个规则有什么问题吗?我怎样才能让它发挥作用。我希望这只作为代理规则。
答案 0 :(得分:1)
你有一个多余的(和矛盾的)RewriteCond
。试试这个规则:
RewriteCond %{QUERY_STRING} ^name=([^&]+) [NC]
RewriteRule ^anotherserver(/.*)?$ http://%1-mywebsite.com/$1 [NC,P,L]
问题是这个条件:
RewriteCond %{REQUEST_URI} !^/anotherserver.* [NC]
如果URI不是以/anotherserver
开头并且您的模式与^anotherserver
匹配,则表示执行规则。