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

完整如下

  1. server
  2. {
  3. listen 80;
  4. #listen [::]:80 default_server ipv6only=on;
  5. server_name jiqing.dexin.com;
  6. index index.html index.htm index.php admin.php;
  7. root /home/wwwroot/default/dexin/dragon/public;
  8. #error_page 404 /404.html;
  9. include enable-php-pathinfo.conf;
  10. location /nginx_status
  11. {
  12. stub_status on;
  13. access_log off;
  14. }
  15. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  16. {
  17. expires 30d;
  18. }
  19. location ~ .*\.(js|css)?$
  20. {
  21. expires 12h;
  22. }
  23. location ~ /\.
  24. {
  25. deny all;
  26. }
  27. location / {
  28. if (!-e $request_filename) {
  29. rewrite ^(.*)$ /index.php?s=/$1 last;
  30. }
  31. }
  32. access_log /home/wwwlogs/access.log;
  33. }

它的功能很简单,如果请求的文件不存在,自动加上index.php。

这样,它既支持index.php/Home/index。也支持/Home/index

nginx 配置隐藏index.php效果的更多相关文章

  1. nginx配置隐藏index.php

    Nginx 服务器隐藏 index.php 配置   location / { try_files $uri $uri/ /index.php?$query_string; }   nginx配置中t ...

  2. Nginx配置 隐藏入口文件index.php

    Nginx配置文件里放入这段代码 server { location / { index index.php index.html index.htm l.php; autoindex on; if ...

  3. Nginx如何隐藏index.html

    我要隐藏目录下的index.html,修改Nginux配置如下: 1.修改文档顺序 index  index.html index.php 2.开启目录流量 在server或location 段里添加 ...

  4. Nginx下隐藏index.php

    在用NGINX搭建web网站时遇到一个问题,那就是除了网站的首页能够正常打开,其他的子网站都打不开,显示找不到文件.但是如果你在网址后面加上index.php,子网站就又可以打开了.那么我们怎么才能不 ...

  5. nginx 配置使用index.php作为目录的默认加载文件

    配置如下: 在server增加一行: index index.php index.html index.htm default.php default.htm default.html 增加后如下: ...

  6. nginx 重写 隐藏index.php

    修改 nginx.conf 文件location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break ...

  7. Nginx隐藏index.php和配置vhost

    nginx启动命令 启动:nginx停止:nginx -s stop退出:nginx -s quit重启:nginx -s reopen重新加载:nginx -s reload平滑启动:kill -H ...

  8. nginx 隐藏 index.php 和 开启 pathinfo 模式的配置

    nginx 通过 location 的规则匹配将 php 转发给 php-fpm 处理后获取结果然后返回给客户端,转发模式可以通过 unix sock 或 tcp socket 方式.百度了好多文章我 ...

  9. TP5框架 nginx服务器 配置域名 隐藏index.php

    server { listen ; #server_name localhost; server_name hhy.com;/**这里写自己的域名*/ #charset koi8-r; #access ...

随机推荐

  1. XamlParseException异常

    一般出现System.Windows.Markup.XamlParseException的错误是由1.dll库加载错误,查询一下你程序中引用的dll你是否加载并引用到程序内.2.程序中引用的文件(tx ...

  2. bash echo color

    原文:https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux $ ; i ...

  3. cassandra框架模型之二——存储机制 CommitLog MemTable SSTable

    四.副本存储 Cassandra不像HBase是基于HDFS的分布式存储,它的数据是存在每个节点的本地文件系统中. Cassandra有三种副本配置策略: 1) SimpleStrategy (Rac ...

  4. OLED取模笔记

  5. LeetCode OJ:Reverse Linked List II(反转链表II)

    Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1-> ...

  6. Android性能调优实例

    本文主要分享自己在appstore项目中的性能调优点,包括同步改异步.缓存.Layout优化.数据库优化.算法优化.延迟执行等. 目前性能优化专题已完成以下部分: 性能优化总纲——性能问题及性能调优方 ...

  7. springmvc用来绑定参数的注解(转)

    引言: 原文链接:http://blog.csdn.net/kobejayandy/article/details/12690161 接上一篇文章,对@RequestMapping进行地址映射讲解之后 ...

  8. Week03-Java学习笔记第三次作业

    Week03-面向对象入门 1.本周学习总结 初学面向对象,会学习到很多碎片化的概念与知识.尝试学会使用思维导图将这些碎片化的概念.知识点组织起来.请使用工具画出本周学习到的知识点及知识点之间的联系. ...

  9. android自定义view系列:认识activity结构

    标签: android 自定义view activity 开发中虽然我们调用Activity的setContentView(R.layout.activity_main)方法显示View视图,但是vi ...

  10. JAVA视频链接

    Java基础Java马士兵:链接:https://pan.baidu.com/s/1jJRvxGi密码:v3xb Java刘意:链接:https://pan.baidu.com/s/1kVZQCqr密 ...