nginx配置伪静态以及nginx开启PHP及pathinfo支持的方法

我这里的文件名是index.php
配置伪静态:

location / {

  if (!-e $request_filename){

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

  }

}

nginx开启PHP及pathinfo支持的方法

location ~ \.php(.*)$ {

  root D:/wwwroot; #你的网站目录

  fastcgi_pass 127.0.0.1:9000; #php-cgi监听地址

  fastcgi_index index.php; #默认页

  fastcgi_split_path_info ^(.+\.php)(.*)$; #分离路径

  fastcgi_param PATH_INFO $fastcgi_path_info; #添加PATH_INFO信息

  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

  fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

  include fastcgi_params;

}

配置完成之后使用命令

nginx -t

检查是否存在错误,如果存在类似下面这样的错误

 directive is duplicate

说明配置重复了,只需要根据提示将其具体的行删除即可

猜你喜欢

转载自blog.csdn.net/weixin_42424269/article/details/89086667