Mobile app version of vmapp.org
Login or Join
Eichhorn148

: Redirect www to non-www only for https:// 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

@Eichhorn148

Posted in: #Htaccess #ModRewrite

I can't seem to find a nice way to redirect www.x.co.uk to x.co.uk whilst letting x.co.uk and 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 x.co.uk/ [R=301,L]


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

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Eichhorn148

1 Comments

Sorted by latest first Latest Oldest Best

 

@Jessie594

Try something like this:

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


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

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme