Take the 2-minute tour ×
Server Fault is a question and answer site for 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

1 Answer 1

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

Your Answer


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