【问题标题】:Why the url read as file or directory by the nginx server?为什么 nginx 服务器将 url 读取为文件或目录?
【发布时间】:2017-12-25 13:30:28
【问题描述】:

2017/07/20 06:05:34 [错误] 19472#0: *25 open() "/home/websites/gamoto.net/test/categoria/secondi-di-carne" 失败(2:否此类文件或目录),客户端:175.158.201.6,服务器:test.gamoto.net,请求:“GET /categoria/secondi-di-carne HTTP/1.1”,主机:“test.gamoto.net”,引用者:“ http://test.gamoto.net/"

这里有错误日志。

【问题讨论】:

  • 为什么不应该呢?有什么问题?
  • 我不知道可能是因为我使用的重写规则?
  • 也许吧。显示 nginx 配置
  • 已经在下面发布了 :) 也许你可以帮忙。提前致谢

标签: nginx webserver nginx-location


【解决方案1】:
server {
  listen 80;

  server_name w4.gamoto.net;

  root "R:/gamoto.net/test_html/";

  index index.php;
  #autoindex off;
  location / {
    rewrite ^/chi-siamo/?([a-z-]*)?/?$ /chi-siamo.php?chi=$1 last;
    rewrite ^/categoria/?([a-z-]*)?/?([a-z0-9-]*)?/?$ /categoria.php?cat=$1&id=$2 last;
    rewrite ^/nazione/italia/?([0-9]*)?/?$ /nazione.php?nazione=italia&pg=$1 last;
    rewrite ^/nazione/italia/?([a-z0-9-]*)?/?([a-z0-9-]*)?/?$ /nazione.php?nazione=italia&regione=$1&id=$2 last;
    rewrite ^/nazione/?([a-z-]*)?/?([0-9-]*)?/?$ /nazione.php?nazione=$1&id=$2 last;
    rewrite ^/ricerca/?([a-z0-9-]*)?/?([0-9]*)?/?$ /ricerca.php?search=$1&pg=$2 last;
  }

  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass php_upstream;      
    #fastcgi_pass unix:var/run/php/php7.0-fpm.sock;
    #fastcgi_split_path_info ^(.+\.php)(/.+)$;
  }


  charset utf-8;

  location = /favicon.ico { access_log off; log_not_found off; }
  location = /robots.txt  { access_log off; log_not_found off; }
  location ~ /\.ht {
    deny all;
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-18
    • 2012-06-23
    • 2013-04-26
    • 1970-01-01
    • 1970-01-01
    • 2021-06-29
    • 2015-11-26
    • 2012-08-27
    相关资源
    最近更新 更多