如何将HTTP重定向到https和https:// WWW到https:// [英] How to redirect http to https and https://www to https://

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

问题描述

我需要重写规则帮助。

所以,我想,这些地址:

  http://domain.com
http://www.domain.com
https://www.domain.com
 

跳转到:

  https://domain.com
 

有人能帮助我吗?

现在我有规则:

 的RewriteCond%{} SERVER_PORT 80
重写规则^(。*)$ https://domain.com/$1 [R,L]

但它不重定向https://开头WWW到https://
 

解决方案

将在 DOCUMENT_ROOT /的.htaccess 文件的规则:

  RewriteEngine叙述上

的RewriteCond%{} HTTPS关闭[OR]
的RewriteCond%{HTTP_HOST} WWW \。
重写规则^的https://domain.com% {REQUEST_URI} [L,R = 301,NE]
 

I need help with rewrite rules.

So I want that these addresses:

http://domain.com
http://www.domain.com
https://www.domain.com

Redirect to:

https://domain.com

Can someone help me?

Right now I have rule:

RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://domain.com/$1 [R,L]

But it doesnt redirect https://www to https://

解决方案

Place this rule in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On

RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} www\.
RewriteRule ^ https://domain.com%{REQUEST_URI} [L,R=301,NE]

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

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