访问被拒绝,除非我添加尾随/

时间:2019-10-14 作者:simo

我正在尝试将wordpress作为子目录添加到rails中,如果我尝试访问博客根页面而不拖尾/或添加/索引。php访问被拒绝。

https://example.com/blog 403

https://example.com/blog/ 200

https://example.com/blog/index.php 200
这是我的配置:

location /blog {
  root /var/www/example/current;  

  fastcgi_intercept_errors on;
  include fastcgi_params;
  fastcgi_index  index.php;   
  fastcgi_param   PATH_INFO         $fastcgi_path_info;
  fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

location ~* \\.(?:css|js|map|jpe?g|gif|png)$ { }
  index  index.html index.htm index.php;
  try_files $uri $uri/ /index.php?$args;
    fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
nginx错误日志:

Access to the script \'/var/www/example/current/blog\' has been denied (see security.limit_extensions)" while reading response header from upstream
/etc/php/7.2/fpm/pool。d/www.conf:

security.limit_extensions = .php .php3 .php4 .php5 .php7 .js .css
有什么想法吗?

1 个回复
SO网友:simo

我找到了答案,我把它放在这里,以防对某人有用:

更改:location /blog 进入location /blog/