rewrite https and www

≡放荡痞女 提交于 2020-01-06 15:25:34

问题


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:


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]


来源:https://stackoverflow.com/questions/37646915/rewrite-https-and-www

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!