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 中的域名 + 目录名 + /。

  • 相关阅读:
    看门狗定时器
    fork 和 exec
    openwrt procd分析
    减肥经验总结
    gcc
    laravel5验证码
    laravel5通过auth.attempt事件加入登陆验证码
    双向链表
    mysql5.6源码安装
    laravel4通过控制视图模板路劲来动态切换主题
  • 原文地址:https://www.cnblogs.com/jedi1995/p/11320357.html
Copyright © 2011-2022 走看看