Nginx URL跳轉


配置需求

注:$document_uri  表示訪問的url
需求:訪問 www.abc.com  請求到 www.abc.com/abc/

使用操作

1、在nginx配置文件中加入

if ($document_uri !~ 'abc')
{
    rewrite ^/(.*)$ http://www.abc.com/abc/$1 permanent;
}
配置文件
    而不是單獨加一句  rewrite ^/(.*)$ http://www.abc.com/abc/$1 permanent;
    如果只加rewrite 規則,而不限定條件,那么會造成死循環。  會訪問到   http://www.abc.com/abc/abc/abc/abc/....
說明

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM