apache永久重定向所有请求到另一个端口

问题描述 投票:1回答:1

如何配置Apache将所有请求从端口80重定向到端口8080?例如,http://google.com.localhost必须重定向到http://google.com.localhost:8080但是对于所有请求。

<VirtualHost *:80>
ServerName proxy.localhost
ServerAlias *.localhost

Redirect permanent / *:8080
</VirtualHost> 
apache redirect
1个回答
0
投票

你不能使用Redirect,因为Redirect不允许变量。

灵感来自使用mod_rewriteApache documentation的例子:

RewriteEngine On
RewriteRule "^/?(.*)" "http://%{HTTP_HOST}:8080/$1" [L,R,NE]

请注意,您需要启用mod_rewrite才能工作。

© www.soinside.com 2019 - 2024. All rights reserved.