nginx 下 yii 隐藏 index.php

vhosts.conf中添加

#nginx ignore index.php
if (!-e $request_filename){  
  rewrite ^/(.*) /index.php last;  
}        

一个网站完整配置

server {
        listen       8848;
        server_name  hyx.com hyx.com;
        root   "D:/phpstudy_prol/WWW/hyx_wuliu_api/web";
        location / {
            index index.php index.html;
            autoindex  off;
            #nginx ignore index.php
            if (!-e $request_filename){  
              rewrite ^/(.*) /index.php last;  
            }   
        }
        location ~ .php(.*)$ {
            fastcgi_pass   127.0.0.1:9001;
            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_params;
        }
}

 

原文地址:https://www.cnblogs.com/sw-3/p/11213464.html