zoukankan      html  css  js  c++  java
  • nginx url自动加斜杠问题

    一、首先对比说明Nginx以下两个现象:

    1. 访问的uri最后带斜杠

      http://localhost/product/    >>>>  查找 product下的index页面,存在就返回;不存在且未开启自动索引目录选项(指令是:autoindex on),则报403错误

    2. 访问的uri最后不带斜杠

      http://localhost/product     >>>>  查找product文件,存在就返回;若存在product的文件夹,会产生301跳转,且自动将uri补全为http://localhost/product/ ,跳转的域名由server_name_in_redirect 指令控制(下文介绍)

    二、server_name_in_redirect 指令配置

    1、server_name_in_redirect on ,URL 重定向为: server_name 中的第一个域名 + 目录名 + /;例如 配置文件中 server_name  www.baidu.com;  则http://localhost/product   时会重定向到http://www.baidu.com/product/(这是个坑)
    2、server_name_in_redirect off (默认值)URL 重定向为: 原 URL 中的域名 + 目录名 + /。

  • 相关阅读:
    jackson自动将东八区时间转成标准时间
    开发项目和所用时间 感想
    自我介绍
    后缀数组模板
    lucas模板
    后缀数组da3模板
    cf#366....
    第1月2周1天
    第1月2周2天
    第1月1周1天
  • 原文地址:https://www.cnblogs.com/jedi1995/p/11320357.html
Copyright © 2011-2022 走看看