0

I realize this has been discussed before here. But I didn't really get the information I needed from the answers there.

I have a subdomain on sub.domain.com, now I have some people trying to access it using www.sub.domain.com, which is obviously a problem. I need to redirect people trying to use www. to sub.domain.com

I don't have much knowledge with .htaccess or A(Host)/CName but if someone can tell me exactly what records I need to add and what it needs to point to that would help alot.

Community
  • 1
  • 1
user2534723
  • 115
  • 1
  • 2
  • 11

1 Answers1

0

First, you need to add DNS records (either CNAME or A) for www.sub under the domain.com domain, to point to the same place as sub. This will make it so when someone goes to www.sub.domain.com, they go to the same IP address as sub.domain.com.

Second, you need to add this rule to the htaccess file in your webserver's document root:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.sub\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://sub.domain.com/$1 [L,R=301]
Jon Lin
  • 142,182
  • 29
  • 220
  • 220