nginx支持pathinfo并且隐藏index.php

How To Set Nginx Support PATHINFO URL Model And Hide The /index.php/

就像这样

The URL before setting like this:

http://serverName/index.php?m=Home&c=Customer&a=getInformation&id=1

Now like this:

http://serverName/Home/Customer/getInformation/id/1

这是偶的配置:

server {

listen       80;

server_name  mybuy.com;

root   /Users/he/Projects/maibei-backend;

#charset koi8-r;

access_log  /Users/he/weblog/mybuy.com.access.log;

error_log   /Users/he/weblog/mybuy.com.error.log;

location / {

if (!-e $request_filename) {

rewrite  ^(.*)$  /index.php?s=$1  last;

break;

}

index  index.php index.html index.htm;

}

# pass the PHP scripts to FastCGI
server listening on 192.168.1.123:9000

#

location ~ \.php {

fastcgi_pass   127.0.0.1:9000;

fastcgi_index  index.php;

fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

include        fastcgi_params;

set $path_info "";

set $real_script_name $fastcgi_script_name;

if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {

set $real_script_name $1;

set $path_info $2;

}

fastcgi_param
SCRIPT_FILENAME $document_root$real_script_name;

fastcgi_param
SCRIPT_NAME $real_script_name;

fastcgi_param
PATH_INFO $path_info;

}

}

时间: 2024-08-05 03:18:38

nginx支持pathinfo并且隐藏index.php的相关文章

配置nginx支持pathinfo

服务器运行的nginx+php,centos的系统.因需新部署一个网站,需要配置nginx支持pathinfo功能.网上各种查资料,终于搞定. 首先查看php.ini文件,查找cgi.fix_pathinfo=0,如不是0,改为0.重启php程序. 然后修改nginx配置文件: location ~ \.php {                    ------(去掉php后面的$) fastcgi_pass   127.0.0.1:9000; fastcgi_index  index.ph

nginx 404页面处理以及pathInfo和隐藏index.php总述

今天开发公司官网:http://www.zstime.com/,遇到一个问题,如何在nginx下设置pathInfo以及如何隐藏index.php 这里分别来讲解一下: 一.隐藏index.php 隐藏index.php需要修改nginx的配置文件,如果你是使用vhost的,需要修改如conf/vhost/你的文件名.conf 文件,整个文件如下 server { listen 80; server_name www.zstime.com; index index index.html inde

phpshe b2c商城系统配置nginx支持pathinfo和rewrite的写法

找到/usr/local/webserver/nginx/conf/nginx.conf文件(环境配置不一样,路径也可能不一样) 并在server {...省略掉的代码}中添加如下代码即可(如果程序放在根目录下用一级目录代码,放在二级目录,请用二级目录代码),改好后重启nginx: ###############开启pathinfo支持(如果已开启请忽略此处)############## location ~ \.php { fastcgi_pass 127.0.0.1:9000; fastcg

让Nginx支持pathinfo

布尔教育 PHP学习笔记 Nginx服务器默认不支持pathinfo, 在需要pathinfo支持的程序中(如thinkphp),则无法支持"/index.php/Home/Index/index"这种网址. 网上流传的解决办法很多,这里提供一种比较简洁的写法(只需要改动2行代码) # 典型配置 location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_par

配置Nginx支持pathinfo模式

Nginx服务器默认不支持pathinfo, 在需要pathinfo支持的程序中(如thinkphp),则无法支持”/index.php/Home/Index/index”这种网址.网上流传的解决办法很多,这里提供一种比较简洁的写法(只需要改动2行代码)典型配置location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $DOC

centOS7.4 thinkPHP nginx 支持pathinfo和rewrite

server { listen 80; server_name www.demo.com mayifanx.com; root /data/www/demo; index index.php index.html index.htm; #红色部分支持rewrite location / { if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; } } location ~ \.php { fastcgi_pass 127

nginx支持pathinfo

server { root /webserver/www/api; listen 80; server_name api.dnxia.com; location / { if (!-e $request_filename) { rewrite "^/(.*)$" /index.php last; } } location ~\.php{ root /webserver/www/api; index index.php; fastcgi_pass 127.0.0.1:9000; fast

nginx服务器绑定多个域名、支持pathinfo路由、隐藏index.php入口文件

这篇文章仅仅是操作,解释说明部分待更新. 1. 修改nginx的配置文件(我的配置文件在/etc/nginx/nginx.conf) [[email protected] ~]# find / -name nginx.conf [[email protected] ~]# vim /etc/nginx/nginx.conf nginx.conf配置文件的大致结构: ... http{ server{ ... #一个server结构可以对应一个域名 } include vhosts/*.conf

配置nginx,支持php的pathinfo路径模式

nginx模式默认是不支持pathinfo模式的,类似index.php/index形式的url会被提示找不到页面.下面的通过正则找出实际文件路径和pathinfo部分的方法,让nginx支持pathinfo. server { listen 8080; server_name ewifiportal.com; #charset koi8-r; #access_log logs/host.access.log main; location / { root D:/Users/xc/Zend/wo