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 on
RewriteCond %{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