我尝试将Apache设置为代理,最终将JavaScript文件的请求重写为不同的代码库。我有Apache设置并充当代理,但无论我做什么它都不会使用重写规则配置如下所示。
目前这在我的本地机器上毁了。
<VirtualHost *:8000>
RewriteEngine on
RewriteRule "(.*)" "http://127.0.0.1/test.html" [P]
DocumentRoot "c:/wamp/www/ipvproxy"
ServerName ipvproxy
ProxyRequests On
ProxyVia On
<Proxy *>
Order deny,allow
Deny from all
Allow from 127.0.0.1
</Proxy>
工作配置
<VirtualHost aaa.bbb.ccc.ddd:8000>
DocumentRoot "c:/wamp/www/"
CustomLog "c:/wamp/logs/vhost.log" common
ErrorLog "c:/wamp/logs/vhost_error.log"
ProxyRequests On
<Proxy *>
Order deny,allow
Deny from all
Allow from all
</Proxy>
RewriteEngine on
RewriteLog "c:/wamp/logs/rewrite2.log"
RewriteLogLevel 9
RewriteRule .* http://127.0.0.1/test.html
</VirtualHost>
答案 0 :(得分:0)
您应该使用反向代理。
类似的东西:
<VirtualHost *:8000>
DocumentRoot "c:/wamp/www/ipvproxy"
ServerName ipvproxy
ProxyPass / http://127.0.0.1/test.html
ProxyPassReverse / http://127.0.0.1/test.html
</VirtualHost>
然后http://ipvproxy:8000的任何请求都会被转换为http://127.0.0.1/test.html
答案 1 :(得分:0)
事实证明问题在于我使用的wampserver版本。在Windown 7 64位上运行Wampserver 64位有mod_rewrite问题,更改为wampserver 32位,它们都开始工作。