Title: apache permanent redirect all requests to another port
Tags: apache;redirect
Question: How to configure Apache to redirect all requests from port 80 to a port 8080? For example http://google.com.localhost must redirect to a http://google.com.localhost:8080 but for all requests.
<VirtualHost *:80&gt;
ServerName proxy.localhost
ServerAlias *.localhost
Redirect permanent / *:8080
</VirtualHost&gt;
Comment: @CBroe, yeah, I mean for all possible hosts (google, facebook, twitter, ....)

Comment: @symcbean, changed it to ProxyPass

Comment: You mean for all possible host names? I don’t think there is any variable substitution available with the Redirect directive. Use mod_rewrite instead, in a RewriteRule you can access env variables such as the request host name.

Comment: And don't use a permanent redirect until you understand what it does and what you are applying it to.


Here is another answer: You cannot use Redirect for this, because Redirect does not allow for variables.
Inspired by the examples using mod_rewrite from the Apache documentation:
RewriteEngine On
RewriteRule "^/?(.*)" "http://%{HTTP_HOST}:8080/$1" [L,R,NE]
Note that you need mod_rewrite enabled for this to work.

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:09/15/17', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<apache><redirect>', 'Title': 'apache permanent redirect all requests to another port', 'ViewCount': 4247, 'id': 46241270, 'user_AboutMe': None, 'user_AccountId': 8578937.0, 'user_DisplayName': 'andriipal', 'user_Reputation': 13.0, 'user_Views': 12.0, 'user_id': 6427314.0}}