Search code examples
.htaccesssubdomainno-www

www to non www in .htaccess where subdomain already exists


I have found loads of examples of rewrite rules for non www to www but i am just looking to check what the practice is for allowing www. redirects when subdomain already exists...

So let's say i want to enable people to type:

http://www.shop.mysite.com

and have them redirected to

http://shop.mysite.com

Would the sequence below allow this?

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.shop\.mysite\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://shop.mysite.co.uk/$1 [L,R=301]

Yes i know this seems kind of silly but people in my organisation are freaking out about the possibility of people typing out our full subdomain url and including a www. Looking to try and allay their fears.

Sorry for the noob nature of the question.

Kind regards,

C


Solution

  • sure, it works ! You can check your htaccess on http://htaccess.madewithlove.be/