使用htaccess的重定向从http用户到https [英] Use htaccess to redirect users from http to https

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

问题描述

我一点都不熟悉htaccess的。我需要的.htaccess code这将重定向HTTP到HTTPS。我使用低于code:

  RewriteEngine叙述上
的RewriteCond%{} HTTPS!上
重写规则HTTPS(*)://%{HTTP_HOST}%{REQUEST_URI}
 

但主要的问题是,我得到下面的建议,试图测试服务器时速度:

 来加快页面加载时间为您的网站的访问者,删除尽可能多的登陆页面
重定向越好,并进行任何所需的重定向缓存如果可能的。

http://xxxx.com/是一个不可缓存重定向到https://xxxx.com/
 

那么,如何使它可缓存?

解决方案
  

http://xxxx.com/是一个不可缓存的重定向到https://xxxx.com/

错误说明了一切。为了使其在浏览器中使用 R = 301 永久缓存:

  RewriteEngine叙述上

的RewriteCond%{} HTTPS关闭
重写规则^的https://%{HTTP_HOST}%{REQUEST_URI} [L,R = 301,NE]
 

I am not at all familiar with htaccess. I need Htaccess code which will redirect http to https. I am using below code:

RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

But main problem is, I am getting below suggestion, when trying to test server speed:

To speed up page load times for visitors of your site, remove as many landing page
redirections as possible, and make any required redirections cacheable if possible.

http://xxxx.com/ is a non-cacheable redirect to https://xxxx.com/

So, how to make it cacheable ?

解决方案

http://xxxx.com/ is a non-cacheable redirect to https://xxxx.com/

Errors says it all. To make it permanently cacheable in browser use R=301:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]

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

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