Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I can't seem to find a nice way to redirect https://www.x.co.uk to https://x.co.uk whilst letting http://x.co.uk and http://www.x.co.uk keep whatever they want.

Could anyone lend a hand?

I have tried various things, the closest I think I have got is a straight up check like this;

    RewriteCond ^https://www\.x\.co\.uk/$ [NC]
    RewriteRule https://x.co.uk/$1 [R=301,L]

But it doesn't seem to match (or if it is it is ignoring the rewrite rule.

share|improve this question
up vote 1 down vote accepted

Try something like this:

RewriteCond %{HTTPS} ^on$
RewriteCond %{HTTP_HOST} ^www\.x\.co\.uk$
RewriteRule ^(.*)$ https://x\.co\.uk$1 [L,R=301]

This is redirect someone from https://www.x.co.uk to https://x.co.uk and not do anything if they are no on https.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.