Skip to content

Instantly share code, notes, and snippets.

@h3xxx
Created December 19, 2014 15:10
Show Gist options
  • Save h3xxx/4b8dc1526d605966430a to your computer and use it in GitHub Desktop.
Save h3xxx/4b8dc1526d605966430a to your computer and use it in GitHub Desktop.
Apache2 subdomains (different ports) redirection
### from http://serverfault.com/questions/195611/how-do-i-redirect-subdomains-to-a-different-port-on-the-same-server
NameVirtualHost *:80
<VirtualHost *>
ServerAdmin [email protected]
ServerName dev.mydomain.com
ProxyPreserveHost On
# setup the proxy
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://localhost:8888/
ProxyPassReverse / http://localhost:8888/
</VirtualHost>
###---------------------------------
NameVirtualHost *:80
<VirtualHost *:80>
ServerName dev.mydomain.com
redirect / http://mydomain.com:8080/
</VirtualHost>
###---------------------------------
ProxyPreserveHost On
ProxyPass / http://example.com:8080/
ProxyPassReverse / http://example:8080/
###---------------------------------
RewriteEngine on
RewriteCond %{HTTP_HOST} ^dev\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com:8080$1 [R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment