首页 > 代码库 > nginx配置

nginx配置

1、nginx隐藏index.php

  下面是虚拟主机隐藏index.php的一个案例,其中红色的就是隐藏index.php

server {        listen       80;        server_name  www.sand.com alias sand.com;        location / {            root   D:/sandbox_pro/sandbox;            if ( -f  $request_filename/index.php) {                rewrite (.*) $1/index.php;        }        if ( !-f $request_filename )  {                rewrite (.*) /index.php;        }            index  index.html index.htm default.html default.htm index.php default.php app.php u.php;            include        D:/sandbox_pro/sandbox/up-*.conf;        }        autoindex off;        include advanced_settings.conf;        location ~ ^.+\.php {            root          D:/sandbox_pro/sandbox;            fastcgi_pass   bakend;            fastcgi_index  index.php;            fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;            fastcgi_param  PATH_INFO $fastcgi_path_info;            fastcgi_param  PATH_TRANSLATED $document_root$fastcgi_path_info;            include        fastcgi.conf;        }        }#server www.sand.com end}

 

nginx配置