Reputation: 73
I'm trying to redirect http://subdomain.domain.com to http://www.subdomain.domain.com. I've manage my self to make the domain redirection work but i can't make my subdomain work. Does anyone have a clue? It has to be done with .htacces!
Thanks and sorry disturbing.
Upvotes: 0
Views: 1621
Reputation: 41219
RewriteEngine on
#subdomain non-www to www
RewriteCond %{HTTP_HOST} ^sub.domain.com$
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}%{REQUEST_URI} [NC,L,R]
Replace sub.domain.com with your subdomain in the pattern of first condition.
This will redirect
http://sub.domain.com
to
http://www.sub.domain.com
Upvotes: 2
Reputation: 2257
You can do this programmatically with a redirect:
<meta http-equiv="refresh" content="0;URL='http://www.subdomain.domain.com'" />
(the content=0 means don't wait, redirect immediately)
Or you can do this at the domain name level. If you have control over domain.com's DNS entry, you can add an alias so that typing the first domain name actually sends it to the 2nd, then you don't have to worry about doing this in code. With all the different providers and tools, it's impractical to try to explain how to do that, but the site's customer service (or FAQs) would likely have instructions to do so.
Upvotes: 1