使用apache作为转发代理并将所有请求重定向到静态页面
我尝试将 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>
I trying to set up Apache as proxy which will eventually rewrite requests for JavaScript files to a different codes base. I have Apache set up and acting as a proxy but no matter what I do it will not use the rewrite rule config is shown below.
Currently this is all ruining on my local machine.
<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>
Working Config
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该使用反向代理。
类似这样的:
然后任何到达 http://ipvproxy:8000 的请求都将被转换为 http://127.0.0.1/test.html
更多信息 此处 和 此处
You should use reverse proxy.
Something like that:
Then any request come to http://ipvproxy:8000 will be translated to http://127.0.0.1/test.html
More info here and here
事实证明问题出在我使用的 wampserver 版本上。在 Windown 7 64 位上运行 Wampserver 64 位会出现 mod_rewrite 问题,更改为 wampserver 32 位后一切都开始工作。
It turns out the issue lay with the wampserver version I was using. Running Wampserver 64 bit on Windown 7 64 bit has issues with mod_rewrite, changed to wampserver 32 bit and it all started to work.