2015-04-01 52 views
0

這是我的主機文件:Magento的內頁404未找到,但網頁上的nginx服務器獲取

server { 
    root  /path/to/root/domain/html; 
    index index.php; 
    server_name servername.de; 
    location/{ 
    index index.html index.php; 
    try_files $uri $uri/ @handler; 
    expires 30d; 
    } 
    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$ { 
    if (!-e $request_filename) { rewrite//index.php last; } 
    expires off; 
    fastcgi_pass 127.0.0.1:9000; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    fastcgi_param MAGE_RUN_TYPE store; 
    include fastcgi_params; 
} 
} 

我已經改變了「使用服務器網址重寫」爲「是」,從Magento管理面板,使網址搜索引擎優化友好(沒有index.php)。我已經從重新啓動nginx後從管理面板清除了magento緩存。 任何人都可以幫助我發現nginx配置正確或爲什麼會出現此錯誤。

回答

0

我自己固定的問題。我使用的是Plesk,並且有一個選項可以添加額外的nginx指令。我刪除了主機文件「/etc/nginx/conf.d/DOMAIN.conf"(Individual sites section in https://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento。Remember to configure」/etc/nginx/nginx.conf「),並在我的」額外的nginx指令「Plesk中的管理區域。

location/{ 
    index index.html index.php; 
    try_files $uri $uri/ @handler; 
    expires 30d; 
} 

location /. { 
    return 404; 
} 

location @handler { 
    rewrite//index.php; 
} 

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

location ~ .php$ { 
    if (!-e $request_filename) { 
    rewrite//index.php last; 
    } 
    fastcgi_pass fastcgi_backend; 
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 
    include /etc/nginx/fastcgi.conf; 
} 
2

你可以試試這個配置:

server { 
    root  /path/to/root/domain/html; 
    index index.php; 
    server_name servername.de; 

    location/{ 
     index index.html index.php; 
     try_files $uri $uri/ @handler; 
     expires 30d; 
    } 
    location @handler { rewrite//index.php; } 
    location ~* .php/ { rewrite ^(.*.php)/ $1 last; } 
    location ~* .php$ { 
     if (!-e $request_filename) { rewrite//index.php last; } 

     expires off; 

     try_files $uri =404; 
     fastcgi_pass 127.0.0.1:9000; 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     include fastcgi_params; 
     fastcgi_param PATH_INFO $fastcgi_path_info; 
     fastcgi_index index.php; 
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; 

     fastcgi_param MAGE_RUN_CODE default; 
     fastcgi_param MAGE_RUN_TYPE store; 
    } 

    location ^~ /app/    { deny all; } 
    location ^~ /includes/   { deny all; } 
    location ^~ /lib/    { deny all; } 
    location ^~ /media/downloadable/ { deny all; } 
    location ^~ /pkginfo/   { deny all; } 
    location ^~ /report/config.xml { deny all; } 
    location ^~ /var/    { deny all; } 

    location @handler { 
     rewrite//index.php; 
    } 

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

而且,對於這個問題和相關問題,您可以檢查的官方Magento的指南:https://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento

+0

我也試過。謝謝您的回答。 – 2015-04-02 05:47:05

1

這條線對我有所幫助。

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