欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

http自動(dòng)跳轉(zhuǎn)https的配置方法

 更新時(shí)間:2017年03月21日 21:05:15   作者:小東博客  
這篇文章主要介紹了http自動(dòng)跳轉(zhuǎn)https的配置方法,需要的朋友可以參考下

IIs中實(shí)現(xiàn)Http自動(dòng)轉(zhuǎn)換到Https方法介紹 (403跳轉(zhuǎn)對(duì)SEO有一定影響)

1.下載安裝URL重寫模塊:Microsoft URL Rewrite Module

32位:http://download.microsoft.com/download/4/9/C/49CD28DB-4AA6-4A51-9437-AA001221F606/rewrite_x86_zh-CN.msi

64位:http://download.microsoft.com/download/4/E/7/4E7ECE9A-DF55-4F90-A354-B497072BDE0A/rewrite_x64_zh-CN.msi

或者到腳本之家下載:http://www.dbjr.com.cn/softs/479310.html

2.SSL設(shè)置不要勾選(很重要)

3.Web.config添加

<system.webServer>
  <rewrite>
   <rules>
    <rule name="HTTP to HTTPS redirect" stopProcessing="true">
     <match url="(.*)" />
     <conditions>
      <add input="{HTTPS}" pattern="off" ignoreCase="true" />
     </conditions>
     <action type="Redirect" redirectType="Found" url="https://{HTTP_HOST}/{R:1}" />
    </rule>
   </rules>
  </rewrite>
 </system.webServer>

收工!~

以下方法不推薦

1、根據(jù)IIS版本備份以下文件:

IIS6.0 路徑:C:\WINDOWS\Help\iisHelp\common\403-4.htm

IIS7.0以上 路徑:C:\inetpub\custerr\zh-CN\403.htm

2、把以下內(nèi)容全部拷貝替換(403-4或403)里面所有內(nèi)容,保存即可

<HTML><HEAD><TITLE>該頁(yè)必須通過(guò)安全通道查看</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=GB2312">
</HEAD><BODY>
<script type="text/javascript">
var url = window.location.href;
    if (url.indexOf("https") < 0) {
     url = url.replace("http:", "https:");
     window.location.replace(url);
    }
</script>
</BODY></HTML>

注釋:IIS6中,站點(diǎn)屬性-》目錄安全性-》編輯中把“要求安全通道(SSL)”勾選上即可。
IIS7、8中,SSL設(shè)置-》把“要求SSL”勾選即可。

APache 版本

如果需要整站跳轉(zhuǎn),則在網(wǎng)站的配置文件的<Directory>標(biāo)簽內(nèi),鍵入以下內(nèi)容:

RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]

如果對(duì)某個(gè)目錄做https強(qiáng)制跳轉(zhuǎn),則復(fù)制以下代碼:

RewriteEngine on
RewriteBase /yourfolder
RewriteCond %{SERVER_PORT} !^443$
#RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

如果只需要對(duì)某個(gè)網(wǎng)頁(yè)進(jìn)行https跳轉(zhuǎn),可以使用redirect 301來(lái)做跳轉(zhuǎn)!redirect 301 /你的網(wǎng)頁(yè) https://你的主機(jī)+網(wǎng)頁(yè)

Tomcat 版本

需要做兩個(gè)地方改動(dòng)。
1:server.xml 中配置ssl證書的端口要改成默認(rèn)的“443”端口,如果已經(jīng)修改,請(qǐng)直接操作第二步;
2:在web.xml配置文件中添加節(jié)點(diǎn)代碼:如下

<web-app>
.........
<security-constraint>
 <web-resource-collection >
    <web-resource-name >SSL</web-resource-name>
    <url-pattern>/*</url-pattern>
  </web-resource-collection>        
  <user-data-constraint>
  <transport-guarantee>CONFIDENTIAL</transport-guarantee>
  </user-data-constraint>
</security-constraint>
 </web-app>

3:回到server.xml 配置文件中找到80端口的節(jié)點(diǎn),里面有默認(rèn)這個(gè)屬性是 redirectPort="8443" 要改成 “443” 保存重啟即可。

Nginx版本

在配置80端口的文件里面,寫入以下內(nèi)容即可。

server {
  listen  80;
  server_name localhost;
  rewrite ^(.*)$ https://$host$1 permanent; 

  location / {
   root html;
   index index.html index.htm;
  }

javascript單獨(dú)頁(yè)面通用代碼段:以下方法較適合做seo搜索或指定某一個(gè)子頁(yè)單獨(dú)https

在需要強(qiáng)制為https的頁(yè)面上加入以下代碼進(jìn)行處理

<script type="text/javascript">
var url = window.location.href;
    if (url.indexOf("https") < 0) {
     url = url.replace("http:", "https:");
     window.location.replace(url);
    }
</script>

PHP頁(yè)面跳轉(zhuǎn):添加在網(wǎng)站php頁(yè)面內(nèi)

if ($_SERVER["HTTPS"] <> "on") 
{ 
$xredir="https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; 
header("Location: ".$xredir); 
}

http跳轉(zhuǎn)https的方法較多,以上僅供參考。

相關(guān)文章

最新評(píng)論