Categories


Tags


(各种版本) http怎么做自动跳转https?

IIS7以上版本

1. 安装rewrite组件

2. 找到网站根目录web.config文件,替换一下内容(如果没有此文件可以创建一个);

<?xml version="1.0" encoding="UTF-8"?>

<configuration>

<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>

</configuration>

复制代码

3.重启IIS测试访问。

APache 版本

如果需要整站跳转,则在网站的配置文件的<Directory>标签内,键入以下内容:

RewriteEngine on

RewriteCond %{SERVER_PORT} !^443$

RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R=301]

复制代码

如果对某个目录做https强制跳转,则复制以下代码:

RewriteEngine on

RewriteBase /yourfolder

RewriteCond %{SERVER_PORT} !^443$

#RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]

RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

复制代码

如果只需要对某个网页进行https跳转,可以使用redirect 301来做跳转!

redirect 301  /你的网页 https://你的主机+网页

Nginx版本

在配置80端口的文件里面,写入以下内容即可。

server {

listen       80;

server_name  localhost;

rewrite ^(.*)$ https://$host$1 permanent;

location / {

root   html;

index  index.html index.htm;

}

复制代码

单独页面通用代码段:以下方法较适合指定某一个子页单独https

在需要强制为https的页面上加入以下代码进行处理http-->https

<script language="JavaScript" type="text/JavaScript">

function redirect()

{

var loc = location.href.split(':');

if(loc[0]=='http')

{

location.href='https:'+loc[1];

}

}

onload=redirect

</script>

复制代码

在需要强制为http的页面上加入以下代码进行处理

https-->http

<script language="JavaScript" type="text/JavaScript">

function redirect()

{

var loc = location.href.split(':');

if(loc[0]=='https')

{

location.href='http:'+loc[1];

}

}

onload=redirect

</script>

复制代码

PHP页面跳转:添加在网站php页面内

if ($_SERVER["HTTPS"] <> "on")

{

$xredir="https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];

header("Location: ".$xredir);

}

复制代码

http跳转https的方法较多,以上仅供参考。(本文引用沃通)

来源:景安


Public @ 2013-11-14 15:35:54

万网域名如何转出到西部数码

万网域名如何转出到西部数码如果需将域名转入西部数码,首先要在万网提交域名转出申请。注意,开启了“域名隐私保护服务”、“禁止域名转出万网两项服务”的域名无法直接转出,需要先关闭域名隐私保护服务。blob.png万网域名转出步骤具体操作如下:http://dc.www.net.cn/basic/transferOut.htmblob.png在左侧菜单中进入【域名转出万网】blob.png1、验证手机b

Public @ 2016-01-19 16:00:01

域名的基本知识

域名(Domain Name),是由一串用点分隔的名字组成的Internet上某一台计算机或计算机组的名称,用于在数据传输时标识计算机的电子方位(有时也指地理位置)。域名的主要目的是为了便于记忆服务器的地址,域名由若干部分组成,各部分之间用小数点分开,可以是字母或数字等,域名前加上传输协议信息及主机类型信息就构成了网址(URL)。DNS(域名系统,Domain Name System)是互联网的一

Public @ 2012-11-03 16:00:19

更多您感兴趣的搜索

0.437385s