如何配置Apache将所有请求从端口80重定向到端口8080?例如,http://google.com.localhost必须重定向到http://google.com.localhost:8080但是对于所有请求。
<VirtualHost *:80>
ServerName proxy.localhost
ServerAlias *.localhost
Redirect permanent / *:8080
</VirtualHost>
你不能使用Redirect
,因为Redirect
不允许变量。
灵感来自使用mod_rewrite
的Apache documentation的例子:
RewriteEngine On
RewriteRule "^/?(.*)" "http://%{HTTP_HOST}:8080/$1" [L,R,NE]
请注意,您需要启用mod_rewrite
才能工作。