Sub-domain --> Sub-domain

Connect with other users about what to run on your webhosting (and how to run it) here.
Post Reply
Asphexis
New to forums
New to forums
Posts: 4
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Wed Dec 18, 2013 3:13 am

Sub-domain --> Sub-domain

Post by Asphexis »

How can I, if at all possible, redirect one sub-domain to another? For example.. http://website.com --> http://www.website.com
User avatar
Spray
Former staff
Former staff
Posts: 630
Joined: Wed Dec 28, 2011 10:41 pm
Location: Oregon

Re: Sub-domain --> Sub-domain

Post by Spray »

Redirecting one subdomain to another can be accomplished using a "forward" record on the domains tab, simply input the URL of the subdomain you're wanting to forward to. Based on your example, however, it appears you're wanting to redirect to include "www" in your URL at all times. If this is the case, a .htaccess rule would be more appropriate.

For this, you would create a .htaccess file inside of your public directory, and insert the following lines:

Code: Select all

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Asphexis
New to forums
New to forums
Posts: 4
Joined: Wed Dec 18, 2013 3:13 am

Re: Sub-domain --> Sub-domain

Post by Asphexis »

Thank you! That worked perfectly.
Post Reply