Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

greetings all, i have multi sub-domain on my domainname.com , i need to redirect www.*.domainname.com to *.domainname.com

ex: http://www.sub1.domainname.com to http ://sub1.domainname.com

any ideas how to do so ?

share|improve this question
add comment

1 Answer

You can do it with mod_rewrite:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.domainname.com$ [NC]
RewriteRule ^(.*)$ http://domainname.com/$1 [R=301,L]

Before using it, make sure you have enabled mod_rewrite first.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.