2015-02-11 123 views
1

我正在使用Nginx和PHP-FPM開發與Magento的電子商務。Nginx和PHP-FPM阻止文件夾中包含「php」的名稱

我有一個名爲「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 

親切的問候,

威廉Bertan

+1

不確定這一點,但請嘗試替換'location〜* .php/{rewrite ^(。*。php)/ $ 1 last; }'by'location〜* .php/{rewrite ^(。*。php)/ $ 1 last; }' – 2015-02-11 11:29:10

+0

太棒了!爲我發佈一個答案給你正確的答案!謝謝! – 2015-02-11 11:33:03

+0

我畢業了! :) – 2015-02-11 11:37:45

回答

4

嘗試更換行:

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

通過

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

我希望它能幫助!

相關問題