我正在用fastcgi開發Nginx上的多語言Magento。一切正常,除非我似乎無法像使用Apache一樣獲取URL。如何重寫Magento的多語言SEO URL的Nginx
我想從url中刪除index.php。例如:
/es/index.php/category.html到 /es/category.html
也是英文 /index.php/category.html到 /category.html
就這樣。
附加信息:
我試圖在管理設置「使用服務器網址重寫」到是。這隻適用於英語,即默認,但是,除了在主頁之外,我得到了西班牙語404,!
如果我在管理中將「使用Web服務器重寫」設置爲否,那麼除了將index.php添加到URL之外,所有內容都可以正常工作。但是,如果我手動刪除URL的index.php頁面仍然會去404。
此外,在Magento管理我有像這樣的基本URL設置:https://www.examplesite.com/es/和{{secure_base_url}} ../皮膚/等。
我有一個文件夾在我的根/ ES /像這樣的index.php文件的副本:
/* Store or website code */
$mageRunCode = isset($_SERVER['MAGE_RUN_CODE']) ? $_SERVER['MAGE_RUN_CODE'] : '';
/* Run store or run website */
$mageRunType = isset($_SERVER['MAGE_RUN_TYPE']) ? $_SERVER['MAGE_RUN_TYPE'] : 'store';
Mage::run('es');
這裏是我的配置爲Nginx的:
worker_processes 1;
error_log /mba/nginx/logs/error.log;
pid /mba/nginx/logs/nginx.pid;
events {
worker_connections 2048;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 64;
open_file_cache max=100 inactive=1m;
open_file_cache_valid 20s;
open_file_cache_min_uses 1;
open_file_cache_errors on;
fastcgi_buffers 256 4k;
ignore_invalid_headers on;
client_header_buffer_size 1k;
client_body_buffer_size 64k;
large_client_header_buffers 4 8k;
client_body_timeout 60;
client_header_timeout 60;
keepalive_requests 100;
keepalive_timeout 300 300;
keepalive_disable msie6;
send_timeout 60;
max_ranges 1;
reset_timedout_connection on;
sendfile on;
sendfile_max_chunk 512k;
server_tokens off;
log_format main '$remote_addr - $remote_user [$time_local] "$request "'
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /mba/nginx/logs/access.log main;
autoindex off;
map $scheme $fastcgi_https { ## Detect when HTTPS is used
default off;
https on;
}
gzip on;
gzip_static on;
gzip_disable "MSIE [1-6]\.";
gzip_vary on;
gzip_comp_level 2;
gzip_min_length 0;
gzip_proxied any;
gzip_types text/plain image/x-icon image/bmp text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
proxy_buffering on;
#proxy_cache_path /mba/nginx/proxy levels=1:2 keys_zone=one:15m inactive=7d max_size=1000m;
proxy_buffer_size 4k;
proxy_buffers 100 16k;
proxy_connect_timeout 60;
proxy_send_timeout 60;
proxy_read_timeout 60;
#include /mba/nginx/conf.d/*.conf;
##
# SSL Support
##
map $scheme $fastcgi_https {
default off;
https on;
}
server {
listen 80;
#listen 443 default ssl;
expires max;
add_header Cache-Control public;
#ssl_certificate /openssl/ssl/www_mybelovedangels_com.crt;
#ssl_certificate_key /openssl/ssl/www_mybelovedangels_com.key;
#access_log /mba.nginx.1/mba/nginx/logs/access_log;
root /mba.nginx.1/mba/www;
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires +60d;
log_not_found off;
}
location/{
index index.html index.php;
try_files $uri $uri/ @handler;
expires +30d;
deny 192.168.1.1;
allow 192.168.1.0/24;
allow 127.0.0.1;
allow 2620:100:e000::8001;
deny all;
}
# Deny access to specific directories no one
# in particular needs access to anyways.
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; }
# Allow only those who have a login name and password
# to view the export folder. Refer to /etc/nginx/htpassword.
location /var/export/ {
auth_basic "Restricted";
auth_basic_user_file htpasswd;
autoindex on;
}
# Deny all attempts to access hidden files
# such as .htaccess, .htpasswd, etc...
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
# This redirect is added so to use Magentos
# common front handler when handling incoming URLs.
location @handler {
rewrite//index.php;
}
# Forward paths such as /js/index.php/x.js
# to their relevant handler.
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
# Handle the exectution of .php files.
location ~ .php$ {
if (!-e $request_filename) {
rewrite//index.php last;
}
expires off;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE en;
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params;
}
}
}
希望這不是很多信息,但可能需要。我在網上無處不在,我無法理解如何做到這一點。
感謝
我沒有虛擬主機,因爲它只是一個有兩個存儲視圖的域。我還需要爲此設置一個虛擬主機嗎? – qrs
我在C:\ mba中得到重複的位置「/」... – qrs
我在C:\ mba中得到重複的位置「/」...或者「try_files」指令在C:\ mba ...中重複或未知指令C:\ mba中的「$ uri」...當我嘗試添加此代碼時。我讀過的所有關於虛擬主機的教程都是關於像這樣設置多個域的:http://gerardmcgarry.com/blog/setting-a-virtual-host-nginx如果我嘗試設置虛擬主機,我最終會一個副本。我將如何去解決這個問題,因爲它似乎需要創建一個名爲domain-somewhere.com和另一個domain-somewhere.com/es/的文件。哎呀,我一直打「返回」,它發佈!然後它說:「對不起,你花了五分鐘!」 – qrs