国产成人精品无码青草_亚洲国产美女精品久久久久∴_欧美人与鲁交大毛片免费_国产果冻豆传媒麻婆精东

18143453325 在線咨詢(xún) 在線咨詢(xún)
18143453325 在線咨詢(xún)
所在位置: 首頁(yè) > 營(yíng)銷(xiāo)資訊 > 建站知識(shí) > nginx重定向

nginx重定向

時(shí)間:2023-02-09 04:06:01 | 來(lái)源:建站知識(shí)

時(shí)間:2023-02-09 04:06:01 來(lái)源:建站知識(shí)

方法一

server { listen 80; server_name localhost; #使用原域名 rewrite ^(.*)$ https://$host$1 permanent; #或者直接定義域名 rewrite ^(.*)$ https://xxx.com permanent; location / { index index.php index.html index.htm; }}

方法二

server { listen 80; server_name localhost; #使用原域名 return 301 https://$server_name$request_uri; #或者直接定義域名 return 301 https://xxx.com; location / { index index.php index.html index.htm; }}

說(shuō)明一下nginx的rewrite方法

語(yǔ)法:rewrite regex replacement[flag];

應(yīng)用位置:server、location、if

rewrite 最后一項(xiàng)flag參數(shù):break、last、redirect、permanent

redirect和permanent

這兩個(gè)flag都是進(jìn)行重定向(302臨時(shí), 301永久),重定向以后的url也會(huì)顯示在地址欄,這兩個(gè)flag會(huì)中斷流程,區(qū)別是對(duì)seo的影響,redirect爬蟲(chóng)不會(huì)更新URL,permanent爬蟲(chóng)會(huì)更新URL

break和last

這兩個(gè)flag都會(huì)中斷當(dāng)前的rewrite流程,不再繼續(xù)匹配后續(xù)的rewrite指令。

如果是在 server的頂級(jí)部分,兩者的作用相同,跳過(guò)剩下的rewrite指令,進(jìn)入localtion匹配

,如果rewrite是在server區(qū)塊頂級(jí)if內(nèi)部,和直接放在server下級(jí)的rewrite行為是一致的。

兩者的區(qū)別在于當(dāng)rewrite指令存在于localtion區(qū)塊時(shí),last會(huì)跳出localtion塊,繼續(xù)后續(xù)的localtion匹配。而break會(huì)跳過(guò)后續(xù)的localtion下的rewrite規(guī)則,執(zhí)行其他指令。

關(guān)鍵詞:

74
73
25
news

版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。

為了最佳展示效果,本站不支持IE9及以下版本的瀏覽器,建議您使用谷歌Chrome瀏覽器。 點(diǎn)擊下載Chrome瀏覽器
關(guān)閉