您好,登錄后才能下訂單哦!
這篇文章主要介紹了百度https認(rèn)證提示"請(qǐng)將您的http站點(diǎn)301重定向到https站點(diǎn)"怎么辦,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
最近想把一個(gè)網(wǎng)站改造成https訪問,但是一些都做好了,去百度站長平臺(tái)認(rèn)證https,結(jié)果怎么提交都是出現(xiàn)“請(qǐng)將您的http站點(diǎn)301重定向到https站點(diǎn)”,在百度站長社區(qū)提問也沒有人回答,最后只能自己摸索。后面找到了原因:原來百度的https認(rèn)證是嚴(yán)格遵守301重定向的,我用的是iis6,之前的代碼為:
RewriteEngine On RewriteCond %{SERVER_PORT} !^443$ RewriteRule (.*) https://%{SERVER_NAME}/$1 [R]
這種寫法雖然能夠?qū)崿F(xiàn)將http全部跳轉(zhuǎn)到https,但是在百度站長平臺(tái)是通不過的。最后將代碼修改為以下后便通過了
RewriteEngine On RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
下面我搜集整理了各種網(wǎng)站環(huán)境的部署https(ssl)后設(shè)置301跳轉(zhuǎn)的代碼,希望能夠?qū)Υ蠹矣兴鶐椭?/p>
linuxt系統(tǒng) apache環(huán)境
云服務(wù)器:在對(duì)應(yīng)站點(diǎn)根目錄下新建(通過ftp或登錄wdcp管理面板中:站點(diǎn)列表-文管-進(jìn)入public_html-創(chuàng)建文件)一個(gè)文件命名為.htaccess。
虛擬主機(jī):可以通過ftp或登錄后進(jìn)入到主機(jī)管理面板-文件管理,進(jìn)入wwwroot,新建一個(gè)文件命名為.htaccess文件,保存即可。
編輯.htaccess文件寫入以下規(guī)則:
<IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{HTTP:From-Https} !^on$ [NC] RewriteRule ^(.*)$ https://www.abc.com/$1 [R=301,L] # www.abc.com對(duì)應(yīng)修改為您自已的域名 RewriteCond %{HTTP_HOST} !^www\. RewriteRule ^(.*)$ https://www.abc.com$1 [R=301,L] # www.abc.com對(duì)應(yīng)修改為您自已的域名 </IfModule>
Nginx環(huán)境
編輯nginx站點(diǎn)配置文件(登錄wdcp管理面板中:站點(diǎn)列表-文管-虛擬主機(jī)站點(diǎn)文件nginx-對(duì)應(yīng)站點(diǎn)配置文件),添加以下規(guī)則
server { listen 80; server_name abc.com; rewrite ^(.*) https://www.abc.com$1 permanent; # abc.com對(duì)應(yīng)修改為您自已的域名 }
Windows系統(tǒng) II7環(huán)境
云服務(wù)器:在對(duì)應(yīng)站點(diǎn)根目錄下新建(通過ftp或登錄后直接進(jìn)入到D:\wwwroot\站點(diǎn)ftp命名目錄\wwwroot創(chuàng)建)一個(gè)文件命名為web.config并編輯添加以下規(guī)則:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="301" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTPS}" pattern="^on$" negate="true" /> </conditions> <action type="Redirect" url="https://www.abc.com/{R:1}" redirectType="Permanent" /> # www.abc.com對(duì)應(yīng)修改為您自已的域名 </rule> </rules> </rewrite> </system.webServer> </configuration>
虛擬主機(jī):可以通過ftp或登錄后進(jìn)入到主機(jī)管理面板-文件管理,進(jìn)入wwwroot,新建一個(gè)文件命名為web.config并編輯添加以下規(guī)則:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="301" stopProcessing="true"> <match url="^(.*)$" ignoreCase="false" /> <conditions logicalGrouping="MatchAll"> <add input="{HTTP_FROM_HTTPS}" pattern="^on$" negate="true" /> </conditions> <action type="Redirect" url="https://www.abc.com/{R:1}" redirectType="Permanent" /> # www.abc.com對(duì)應(yīng)修改為您自已的域名 </rule> </rules> </rewrite> </system.webServer> </configuration>
Windows系統(tǒng) II6環(huán)境
配置一個(gè)Rewrite,編輯該Rewrite的規(guī)則文件httpd.conf或者.htaccess 添加以下規(guī)則。
RewriteEngine On RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
tomcat環(huán)境
在web.xml最后一行</web-app>代碼之前添加如下代碼即可
<security-constraint> <!-- Authorization setting for SSL --> <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>
注: 1、discuz使用301方式強(qiáng)制將http跳轉(zhuǎn)到https后會(huì)導(dǎo)致后臺(tái)uc通信失敗。
2、通過該方式設(shè)置跳轉(zhuǎn)后,如無法正常跳轉(zhuǎn)訪問,請(qǐng)單獨(dú)建立站點(diǎn)綁定https域名,仍在原來站點(diǎn)設(shè)置跳轉(zhuǎn)規(guī)則。
感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“百度https認(rèn)證提示"請(qǐng)將您的http站點(diǎn)301重定向到https站點(diǎn)"怎么辦”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持億速云,關(guān)注億速云行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來學(xué)習(xí)!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。