rewrite https and www

2019-09-10 11:49发布

now I have a website https.

http://www.example.com -> https://www.example.com = OK !

But, I have a problem with www ://example.com -> s://example.com = not good

I would like to have this redirection below : ://example.com -> s://www.example.com

How with RewriteCond and RewriteRule ? Help me plz !

Thanks !

1条回答
老娘就宠你
2楼-- · 2019-09-10 12:09

To enforce https on all requests and redirect to www.example.com

# force https and www
RewriteCond %{HTTPS} off
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R,L]

# if already https without www
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^ https://www.example.com%{REQUEST_URI} [R,L]
查看更多
登录 后发表回答