document.writeln('');

国产精品最大AV站在线观看,a级黄毛片试看三分钟,AV无码A片高潮AV,国产午夜精品一区二区三区,久久爆乳不卡一区,日本三级欧美三级,日韩精品AV一二三区在线,高H短篇小说抽插

當前位置:首頁 > 免費源碼 > 網站http強制http方法

網站http強制http方法

游戲科技網2026年09月15日 06:52免費源碼70

LAMP或者LNMP集成環境跳轉:

首先在網站根目錄下創建.htaccess文件,如果目錄下已經有.htaccess文件,則用vi或者其他編輯器打開,在最下面添加寫入如下語句即可

RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
RewriteEngine on
RewriteBase /
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
RewriteEngine onRewriteBase /RewriteCond %{SERVER_PORT} !^443$RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

Apache服務器:

如果需要整站跳轉,則在網站的配置文件的<Directory>標簽內,鍵入以下內容:

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

如果對某個目錄做https強制跳轉,則復制以下代碼:

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

Nginx服務器:

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

server {
listen 80;
server_name localhost;
rewrite ^(.*)$ https://$host$1 permanent;
location / {
root <a target="_blank" href="https://123vo.cn/tag/31.html" title="View all posts in html">html</a>;
index index.html index.htm;
}
server {
listen       80;
server_name  localhost;
rewrite ^(.*)$ https://$host$1 permanent;
location / {
root   <a target="_blank"  title="View all posts in html">html</a>;
index  index.html index.htm;
}
server {listen80;server_namelocalhost;rewrite ^(.*)$ https://$host$1 permanent;location / {roothtml;indexindex.html index.htm;}

JS跳轉:

以下方法較適合指定某一個子頁單獨https,如果網頁定義了top或者boot文件,可以在這個文件里面加入;

在需要強制為https的頁面上加入以下代碼進行處理http–>https

<script type="text/<a target="_blank" href="https://123vo.cn/tag/35.html" title="View all posts in javascript">javascript</a>">
var url = window.location.href;
if (url.indexOf("https") < 0) {
url = url.replace("http:", "https:");
window.location.replace(url);
}
</script>
<script type="text/<a target="_blank"  title="View all posts in javascript">javascript</a>">
var url = window.location.href;
if (url.indexOf("https") < 0) {
url = url.replace("http:", "https:");
window.location.replace(url);
}
</script>
<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跳轉:

添加在網站php頁面內

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

 

 

內容看完了