1 nginx修改root映射2 通過nginx rewrite內(nèi)部跳轉(zhuǎn)實現(xiàn)訪問重定向

3 nginx設(shè)置別名alias映射實現(xiàn)

4 通過nginx的permanent 301絕對跳轉(zhuǎn)實現(xiàn)

5 通過判斷uri實現(xiàn)頁面跳轉(zhuǎn)

如果希望域名后邊" />

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

18143453325 在線咨詢 在線咨詢
18143453325 在線咨詢
所在位置: 首頁 > 營銷資訊 > 建站知識 > nginx目錄路徑重定向

nginx目錄路徑重定向

時間:2023-02-09 11:15:01 | 來源:建站知識

時間:2023-02-09 11:15:01 來源:建站知識

nginx目錄路徑重定向

目錄

1 nginx修改root映射

2 通過nginx rewrite內(nèi)部跳轉(zhuǎn)實現(xiàn)訪問重定向

3 nginx設(shè)置別名alias映射實現(xiàn)

4 通過nginx的permanent 301絕對跳轉(zhuǎn)實現(xiàn)

5 通過判斷uri實現(xiàn)頁面跳轉(zhuǎn)

如果希望域名后邊跟隨的路徑指向本地磁盤的其他目錄,而不是默認的web目錄時,需要設(shè)置nginx目錄訪問重定向. 應(yīng)用場景:http://dashidan.com/image自動跳轉(zhuǎn)到http://dashidan.com/folderName/image.nginx目錄路徑重定向的四種實現(xiàn)方式.修改root映射,通過Nginx rewrite內(nèi)部跳轉(zhuǎn),設(shè)置別名alias映射實現(xiàn),通過nginx的permanent 301絕對跳轉(zhuǎn)實現(xiàn).

1 nginx修改root映射

修改root映射實現(xiàn)nginx目錄訪問重定向是最簡單的方式, 推薦采用這一種.

location /image { root /folderName; }2 通過nginx rewrite內(nèi)部跳轉(zhuǎn)實現(xiàn)訪問重定向

nginx配置代碼示例:

location /image { rewrite ^/image/(.*)$ /folderName/image/$1 last; }3 nginx設(shè)置別名alias映射實現(xiàn)

配置示例:

location /image { alias /folderName/image; #這里寫絕對路徑 }4 通過nginx的permanent 301絕對跳轉(zhuǎn)實現(xiàn)

配置示例:

location /image { rewrite ^/image/(.*)$ http://dashidan.com/folderName/image/$1; }5 通過判斷uri實現(xiàn)頁面跳轉(zhuǎn)

配置示例:

if ( $request_uri ~* ^(/image)){ rewrite ^/image/(.*)$ /folderName/image/$1 last; }轉(zhuǎn)載請保留本文鏈接.



關(guān)鍵詞:路徑,目錄

74
73
25
news

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

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