带和不带WWW和https //::htaccess的重定向两个HTTP // WWW到https://非www [英] .htaccess redirect both http:// with and without www and https://www to https:// non-www

查看:387
本文介绍了带和不带WWW和https //::htaccess的重定向两个HTTP // WWW到https://非www的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望重定向所有的:

http://
http://www.
https://www.

to https://

这可能已经在这里找到答案之前,但已经经历过,似乎问题有关,他们都不太我后,一切我已经试过导致重定向循环或不工作的希望。

This may have been answered here before, but having gone through the questions that seem relevant they are all not quite what I'm after, and everything I've tried resulted in a redirect loop or not working as hoped.

例如:

RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www.example.com
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]

RewriteCond %{HTTPS_HOST} ^example.com
RewriteRule ^(.*)$ https://example.com/$1 [R=301,L]

在此先感谢您的帮助。

Thanks in advance for your help.

推荐答案

尝试:

RewriteCond %{HTTP_HOST} !^energenie4u\.co\.uk$ [NC,OR]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://energenie4u.co.uk/$1 [R=301,L]

这篇关于带和不带WWW和https //::htaccess的重定向两个HTTP // WWW到https://非www的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆