使用的.htaccess重定向到http://www.domain.com https://www.domain.com [英] Redirect http://www.domain.com to https://www.domain.com using .htaccess

查看:149
本文介绍了使用的.htaccess重定向到http://www.domain.com https://www.domain.com的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我的域名从HTTP重定向到https:

I want to redirect my domain from http to https:

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

这可能吗?我一直在寻找周围的互联网,但我只找到:

Is it possible? I've been searching around the internet but I only found:

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

现在的问题是,如何直接在 http://www.domain.com 到达人民?难道他们不与非HTTPS URL提供服务?一样的,反之亦然。我只是想从HTTP到HTTPS一个简单的重定向。可能吗?

The question is, how about peoples arriving directly on http://www.domain.com? Aren't they be served with non-https url? Same as the vice versa. I just want a simple redirection from the HTTP to HTTPS. Is it possible?

感谢您

推荐答案

它将为PHP的所有版本工作,将迫使SSL和WWW所有裸域和链接:

It will work for ALL versions of php and will force SSL and www to all naked domains and links:

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


  • 我们确实需要NE

  • WWW。是可选的在第4行

  • 关闭必须是。

  • 玩得开心。

    本杰明

    这篇关于使用的.htaccess重定向到http://www.domain.com https://www.domain.com的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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