0

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

CraigF14
  • 3
  • 2
  • Hi Dave, Thanks for getting back to me. I used the link you provided and then tried my snippet out. It isn't working for my specific case... it states that "This condition was not met" and in turn that "This rule was not met because one of the conditions was not met". I should've given a closer example to my url: looking to get www.parents.mysite.co.uk to redirect to parents.mysite.co.uk – CraigF14 Oct 27 '14 at 15:52
  • I think you must check your code, since it works for me. Are you sure your condition starts with ^ and ands with $, and escapes every dot (although this wouldn't mind)? If it still fails, please update your question/comment with the real .htaccess... you can delete the comments afterwards ! – DaveG Oct 27 '14 at 16:07
  • Hi Dave i've updated the original question above – CraigF14 Oct 27 '14 at 16:28

1 Answers1

0

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

DaveG
  • 741
  • 6
  • 16