的說明:
我成立了Magento的與存儲配置是這樣的:Magento的重定向從舊網址新的網址,其中有商店(語言)代碼
- 公司名稱 - Webside
- 總店 - 商店
- 恩 - 商店查看
- DK - 商店查看
- 總店 - 商店
我的鏈接看起來像:https://my-company.com/shop/
然後我reaslised,這是我的需求錯誤的配置,我有改變
- 英語 - Webside
- 總店 - 商店
- EN - 商店查看
- 總店 - 商店
- 丹麥 - Webside
- 總店 - 商店
- DK - 商店查看
- 總店 - 商店
另外,我啓用 Magento的功能 「添加商店代碼到URL」之前被禁用。
現在我的鏈接如下所示:https://my-company.com/EN /店/
問題:
既然我已經做網站地圖,同時變化沒有作出並將其提交給網站管理員,我現在面臨的問題在URL中沒有商店代碼的所有舊鏈接確實不是不是工作(404代碼 - 未找到)。
因爲網絡管理者和其他原因,我真的想實現這個結果的:
當有人試圖打開舊網址是沒有存儲代碼(如https://my-company.com/shop/)之一,我想他是隻需將商店代碼添加爲網址中的第一個網址即可重定向到新網址。
我已經試圖通過向我的nginx配置添加一些重寫規則來達到這個目的,但是我遇到了無限循環,最後我無法找到正確的重寫規則解決方案。 (鏈接到我的nginx的重寫規則問題:Nginx Config Location Regex With Language Code In Url)
全部Nginx的配置:
server {
# Listen on port 8080 as well as post 443 for SSL connections.
listen 8080;
listen 443 default ssl;
server_name example.com www.example.com;
large_client_header_buffers 4 16k;
ssl on;
# Specify path to your SSL certificates.
ssl_certificate /path/top/certificate.crt;
ssl_certificate_key /path/to/key.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:ECDHE-RSA-AES128-GCM-SHA256:AES256+EECDH:DHE-RSA-AES128-GCM-SHA256:AES256+EDH:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
ssl_prefer_server_ciphers on;
ssl_dhparam /path/to/dh_params.pem;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
keepalive_timeout 70;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
ssl_trusted_certificate /path/to/certificate.crt;
# Path to the files in which you wish to store your access and error logs.
access_log /path/to/access_log;
error_log /path/to/error_log;
root /path/to/root/folder;
location ~* "^/(?![a-z]{2}/)(.+)$" {
rewrite //en/$1 permanent;
}
location/{
index index.htm index.html index.php;
try_files $uri $uri/ @handler;
}
# 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?$query_string;
}
# 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_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/path/to/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param HTTPS on;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE en;
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params;
}
}
你可以顯示你的重寫正在產生無限循環?您的重寫可能沒問題,但這個循環是由您的瀏覽器引起的,例如, Chrome的內部DNS chrome:// net-internals /#dns – jdm2112
已更新的問題與代碼片段 –
大概這是(或曾經)正在工作的網站。您正在發佈明確具有重定向循環的代碼段。我想我們需要更多的'nginx'配置來理解爲什麼PHP處理程序被破壞。 –