日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

nginx访问目录是没加/的重定向控制

發(fā)布時間:2023/12/2 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 nginx访问目录是没加/的重定向控制 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

static 模塊提供了root與alias功能;發(fā)現(xiàn)目標是目錄時;但URI末尾未加/時;會返回301重定向;重定向后會加/

指令

?

Syntax: server_name_in_redirect on | off;# 控制返回那個域名 Default: server_name_in_redirect off; Context: http, server, location Syntax: port_in_redirect on | off; #控制返回的端口 Default: port_in_redirect on; Context: http, server, location Syntax: absolute_redirect on | off; #返回重定向時時否添域名,默認是會添域名 Default: absolute_redirect on; Context: http, server, location

  

配置

[root@python vhast]# cat dir.conf server {server_name www.dir.com fwe.dir.com; #第一個為主域名;第二個為輔助域名server_name_in_redirect off;listen 8088;absolute_redirect off;root html/; }

  測試

[root@python vhast]# curl www.dir.com:8088/first -I HTTP/1.1 301 Moved Permanently Server: nginx/1.15.9 Date: Wed, 10 Jul 2019 10:30:04 GMT Content-Type: text/html Content-Length: 169 Connection: keep-alive Location: /first/

  修改配置

server {server_name www.dir.com fwe.dir.com;server_name_in_redirect off;listen 8088;#absolute_redirect off;root html/; }

  測試

[root@python vhast]# curl www.dir.com:8088/first -I HTTP/1.1 301 Moved Permanently Server: nginx/1.15.9 Date: Wed, 10 Jul 2019 10:31:21 GMT Content-Type: text/html Content-Length: 169 Location: http://www.dir.com:8088/first/ Connection: keep-alive

  測試加主機名

root@python vhast]# curl -H "Host:aaa" localhost:8088/first -I HTTP/1.1 301 Moved Permanently Server: nginx/1.15.9 Date: Wed, 10 Jul 2019 10:34:36 GMT Content-Type: text/html Content-Length: 169 Location: http://aaa:8088/first/ Connection: keep-alive

  修改配置

[root@python vhast]# cat dir.conf server {server_name www.dir.com fwe.dir.com;server_name_in_redirect on; #表示修改為主域名在返回的URI里listen 8088;#absolute_redirect off;root html/; }

  測試

[root@python vhast]# curl -H "Host:aaa" localhost:8088/first -I HTTP/1.1 301 Moved Permanently Server: nginx/1.15.9 Date: Wed, 10 Jul 2019 10:36:46 GMT Content-Type: text/html Content-Length: 169 Location: http://www.dir.com:8088/first/ Connection: keep-alive

  

轉(zhuǎn)載于:https://www.cnblogs.com/rdchenxi/p/11171349.html

總結(jié)

以上是生活随笔為你收集整理的nginx访问目录是没加/的重定向控制的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。