Redirect NON-www to www for https

前端 未结 2 1110
悲&欢浪女
悲&欢浪女 2020-12-21 17:11

I\'ve the following redirect

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


        
相关标签:
2条回答
  • 2020-12-21 17:14

    I'm using this on a Joomla site and it redirects everything to https://www I can't see this solution anywhere else so thought I'd share it

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

    0 讨论(0)
  • 2020-12-21 17:36

    You can use the following :

    RewriteCond %{HTTPS} !on [OR]
    RewriteCond %{HTTP_HOST} !^www\.
    RewriteRule (.*) https://www.example.com%{REQUEST_URI} [L,R=301]
    

    This will redirect

    • http://example.com
    • https://example.com

    to

    • https://www.example.com
    0 讨论(0)
提交回复
热议问题