zoukankan      html  css  js  c++  java
  • Nginx环境下隐藏index.php

    Nginx环境

    在Nginx低版本中,是不支持PATHINFO的,但是可以通过在Nginx.conf中配置转发规则实现:

    1. location / { // …..省略部分代码 
    2.   if (!-e $request_filename) { 
    3.     rewrite  ^(.*)$  /index.php?s=$1  last; 
    4.     break; 
    5.   } 

    其实内部是转发到了ThinkPHP提供的兼容模式的URL,利用这种方式,可以解决其他不支持PATHINFO的WEB服务器环境.

    如果你的ThinkPHP安装在二级目录,Nginx的伪静态方法设置如下,其中youdomain是所在的目录名称.

    1. location /youdomain/ { 
    2. if (!-e $request_filename){ 
    3.     rewrite  ^/youdomain/(.*)$  /youdomain/index.php?s=$1  last; 
    4.   } 
    5. }

    举个例子

    1. location /tp/public/ {
      index index.html index.htm index.php l.php;
      autoindex off;
      if (!-e $request_filename) {
      rewrite ^/tp/public/(.*)$ /tp/public/index.php?s=/$1 last;
      break;
      }
  • 相关阅读:
    VS 快捷键
    vue 本地环境API代理设置和解决跨域
    vue-cli 项目配置
    stylus 使用小技巧(1)
    vue 初始化rem
    vue element-ui NavMenu错位问题
    vue 数字输入组件
    vue X-Template
    vue 异步组件
    vue 非父子组件通信
  • 原文地址:https://www.cnblogs.com/linqingvoe/p/10978004.html
Copyright © 2011-2022 走看看