0

I have created .htaccess file rules. when i used without example.co.uk site get redirect to https://www.example.co.uk but when i tried www.example.co.uk then its not redirecting to https://www.example.co.uk

RewriteCond %{HTTP_HOST} ^example\.co.uk$ [NC] 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.co.uk/$1 [R=301,L]

is anyone has any suggestion what went wrong? with this

Manish J
  • 686
  • 1
  • 8
  • 24

1 Answers1

1

Well, your first condition explicitly makes sure that the redirection only will get applied when the requested host name is exactly "example.co.uk". So not "www.example.co.uk". You can change that condition to accept both variants:

RewriteCond %{HTTP_HOST} ^(www\.)?example\.co\.uk$ [NC] 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^ https://www.example.co.uk%{REQUEST_URI} [R=301,END]
arkascha
  • 41,620
  • 7
  • 58
  • 90