1、在vhost-ini文件上配置下面
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
2、完整如下
server {
listen 80;
server_name house.xxx.com ;
root "E:\code\www\html\web\xxx\public";
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
location ~ \.php(.*)$ {
fastcgi_pass 127.0.0.1:9000;
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;
}
}
3、403错误
当访问该网站的时,nginx 会按照 index.html,index.htm ,index.php 的先后顺序在根目录中查找文件。如果这三个文件都不存在,那么nginx就会返回403 Forbidden。
所以,在vhost里没有这段内容直接输入域名访问就会报403的错误,除非你在域名后面加个 /index.php才可以正常访问;