【问题标题】:Nginx and PHP-FPM blocking folder with contains "php" in the name名称中包含“php”的 Nginx 和 PHP-FPM 阻塞文件夹
【发布时间】:2015-02-11 19:36:04
【问题描述】:

我正在使用 Nginx 和 PHP-FPM 与 Magento 开发电子商务。

我有一个名为“boletophp”的文件夹,该站点正在尝试访问此链接:“my.store/skin/boletophp/imagens/logobb.jpg”,Nginx 将链接重写为“my.store/skin/ boletophp/".

我将文件夹名称更改为“boleto”并成功加载图像,但模块无法正常工作。所以文件夹名称需要是“boletophp”。

这是 my.store 配置文件:

server {
    server_name my.store;
    access_log /srv/www/my.store/logs/access.log;
    error_log /srv/www/my.store/logs/error.log;
    root /srv/www/my.store/public_html;

    location / {
        index index.html index.htm index.php;
        try_files $uri $uri/ @handler;
    }

    location ~ ^/(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { internal; }
    location /var/export/ { internal; }
    location /. { return 404; }
    location @handler { rewrite / /index.php; }
    location ~* .php/ { rewrite ^(.*.php)/ $1 last; }

    location ~ \.php$ {
        client_max_body_size 2048M;
        expires off;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /srv/www/my.store/public_html$fastcgi_script_name;
        fastcgi_param MAGE_RUN_CODE default;
        fastcgi_param MAGE_RUN_TYPE store;
    }

    location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
        expires 30d;
        add_header Pragma public;
        add_header Cache-Control "public";
    }
}

版本:

  Nginx: 1.6.2
    PHP: 5.6.5
Magento: 1.9.1

亲切的问候,

威廉·伯坦

【问题讨论】:

  • 不确定,但请尝试将location ~* .php/ { rewrite ^(.*.php)/ $1 last; } 替换为location ~* \.php/ { rewrite ^(.*.php)/ $1 last; }
  • 太棒了!给我发一个答案给你正确的答案!谢谢!
  • 我毕业了! :)

标签: magento nginx php


【解决方案1】:

换行试试:

location ~* .php/ { rewrite ^(.*.php)/ $1 last; } 

location ~* \.php/ { rewrite ^(.*.php)/ $1 last; }

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 2011-10-09
    • 1970-01-01
    • 1970-01-01
    • 2016-02-07
    • 2022-01-03
    • 1970-01-01
    • 1970-01-01
    • 2015-04-29
    • 2021-04-02
    相关资源
    最近更新 更多