我有一个Apache Web服务器,需要反向代理网站。 因此example.com/test/或example.com/test从同一个其他web服务器拉。 我已经build立了一个没有像这样的结尾斜杠的反向代理:
ProxyPass /test http://othersite.com/test ProxyPassReverse /testhttp://othersite.com/test
但它不适用于斜线。
有任何想法吗? 我已经尝试redirect从/testing/到/testing没有运气。
谢谢。
你有没有尝试重写url?
RewriteEngine on RewriteRule ^/test$ /test/ [R] ProxyRequests Off ProxyPreserveHost On ProxyPass /test/ http://othersite.com/test/ ProxyPassReverse /test/ http://othersite.com/test/
你是什么意思,它不适用于后面的斜线? 它redirect到错误的地方吗? 它会给404错误吗? 这是我用来build立一个反向代理,并隐藏来自世界其他地方的来源。
ProxyRequests off <Location /guides> ProxyPass http://blog.domain.com ProxyPassReverse http://blog.domain.com ProxyPassReverse / ProxyHTMLEnable On ProxyHTMLURLMap / /guides ProxyHTMLURLMap http://blogs.domain.com /guides RequestHeader unset Accept-Encoding RequestHeader set MySpecialHeader secretkey #LogLevel proxy:debug </Location>
你可以用它来testing你的代理:
$ curl -I http://localhost:81/guides/top5 HTTP/1.1 301 Moved Permanently Location: http://localhost:81/guides/top5/