Community

how to redirect www.sub.domain.com to sub.domain.com?

how to redirect www.sub.domain.com to sub.domain.com?

After a recent move to a new host I have decided to make my site, a subdomain, stop using 'www'. This greatly helps Boost module save cache space because it doesnt have to cache a www version of the same site.

Some images on my site whose urls are 'www.sub.domain.com/../files/image.jpg' are not appearing now, although they are present at the files dir, just with the wrong image url. Will the solution to the redirect also allow these to appear?

tia!!

Comments

# To redirect all users to

# To redirect all users to access the site WITHOUT the
'www.' prefix, # (http://www.example.com/... will be redirected to http://example.com/...)

Write the following code in .htaccess file
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]

Need Drupal help?
Reach Me
Drupal Developer , Themer.

hi yes i saw this at

hi yes i saw this at .htaccess earlier but it doesn't apply as I am using a subdomain.

I tried
RewriteCond %{HTTP_HOST} ^www\.sub\.domain\.com$ [NC]
RewriteRule ^(.*)$ http://sub.domain.com/$1 [L,R=301]

and it didn't work. any ideas please?
thanks.

its means the your server

its means the your server admin has not given you a permission to override the apache settings. Ask the server admin to give the permission and the try the above code.

Need Drupal help?
Reach Me
Drupal Developer , Themer.

Use the redirect from CPanel.

Use the redirect from CPanel. Check out the options there as I recall you can redirect your subdomains and use www or not.

i dont have cpanel on my vps.

i dont have cpanel on my vps.