简体   繁体   中英

www.example.co.uk is not redirecting to https://www.example.co.uk

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

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]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM