0

I know this is fairly straightforward rewrite but I can not get it working and have searched for similar question.

I have created several sub domains for my client. However, many visitors are still typing www. in front of sub domain. I need rewrite to remove www. before any sub domains.

For example: I have subdomain.mydomain.com If someone enters: www.subdomain.mydomain.com I need to go to: subdomain.mydomain.com

Thank You in Advance Chip

1 Answers1

0

This can work in your vhosts configuration file:

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

Then some command like this to restart apache2:

/etc/init.d/apache2 restart

.

jacouh
  • 8,473
  • 5
  • 32
  • 43
  • doesn't seem to work unless other Rewrites in the file are conflicting RewriteEngine On is already on so I didn't included RewriteCond %{HTTP_HOST} ^www\.bret\.lakerealty\.com [NC] RewriteRule ^(.*)$ http://bret.lakerealty.com$1 [R,L] – user1536440 Nov 04 '13 at 16:32
  • It's strange, I've tested this redirect in vhosts: http ://www.subdomain.example.com/monstrer => http ://subdomain.example.com/monster works with apache2. RedirectEngine On can be repeated many times. – jacouh Nov 04 '13 at 17:07