将下面这句放在nginx.conf配置文件最下面
include vhosts.conf;
然后在nginx.conf所在的目录创建一个名为vhost.conf的文件 用记事本打开在里面输入如下代码
server {
listen 8080;
server_name localhost ;
root D:/wamp/www/;
location / {
index index.html index.htm index.php;
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
#autoindex on;
}
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;
}
}
如需多个域名的话再复制上面代码多次即可但是端口要改掉,其中
if (!-e $request_filename){
rewrite ^/(.*) /index.php last;
}
这部分是urlrewrite去掉index.php用的看自己需要是否删除这块代码