How to domain or subdomain point to different ports ?

Started by Dipak Bhoi, August 17, 2014, 07:02:30 PM

Previous topic - Next topic

Dipak Bhoi

Hello guys,

If you want to domain or subdomain to be forwarded to the different port for different service then this post will help you. Follow the following instructions.

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 file.

In httpd.conf:

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

In .htaccess: Set redirect rule

QuoteRewriteEngine on
RewriteCond %{HTTP_HOST} ^subdomain\.mydomain\.com$ [NC]
RewriteRule ^(.*)$ http://mydomain.com:4040/$1 [R=301]

Enjoy !!!


MilesWeb - 30-Day Money Back
cPanel Web Hosting - cPanel Hosting in India
Grab a Free SSL for your website.  WordPress Optimized Solution.