How to forward a subdomain to a new port on the same IP address using Apache? [closed] How to forward a subdomain to a new port on the same IP address using Apache? [closed] apache apache

How to forward a subdomain to a new port on the same IP address using Apache? [closed]


There are two ways to do this. You could use the VirtualHost section of your httpd.conf or you could do it in your .htaccess. (assuming that the subdomains resolve to the same IP as your webserver)

In httpd.conf:

<VirtualHost *:80>    ServerName subsonic.mydomain.com    redirect / http://mydomain.com:4040/</VirtualHost>

In .htaccess:

RewriteEngine onRewriteCond %{HTTP_HOST} ^subsonic\.mydomain\.com$ [NC]RewriteRule ^(.*)$ http://mydomain.com:4040/$1 [R=301]

Documentation:
- Guide to creating name-based virtual hosts
- Core, including VirtualHost and NameVirtualHost
- Redirect
- mod_rewrite guide