dongruyan4948 2013-05-07 17:02
浏览 169

使用Nginx在OpenCart上的多个商店和子域上启用SEO URL

I am trying to get SEO URLs working across multi-stores in OpenCart.

I have two stores in the admin

http://www.shop.com (default)
http://m.shop.com

SEO URLs work for http://www.shop.com But they return a not_found.tpl (the 404 page) for the http://m.shop.com

This works however:

http://m.shop.com/index.php?route=product/product&path=68&product_id=52

SEO wise, it should be

/index.php?route=product/product&path=68&product_id=52

http://www.shop.com/product-title
http://m.shop.com/product-title (404 returned)

I am using NGINX. This is the config:

www.shop.com

server {
    server_name  www.shop.com;
    listen 80;
    root /var/www/www.shop.com/;
    index index.php index.html;
    location /image/data {
        autoindex on;
    }
    location / {
        try_files $uri @opencart;       
    }
    location @opencart {
        rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }
    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

m.shop.com

server {
    server_name  m.shop.com;
    listen 80;
    root /var/www/www.shop.com/;
    index index.php index.html;
    location /image/data {
        autoindex on;
    }
    location / {
        try_files $uri @opencart;       
    }
    location @opencart {
        rewrite ^/(.+)$ /index.php?_route_=$1 last;
    }
    location ~ \.php$ {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}
  • 写回答

2条回答 默认 最新

  • doudao0660 2013-05-13 08:54
    关注

    OpenCart does not handle SEO URLs for multi-stores. The only way to do this - manually add the URLs within the location {} of the m.shop.vhost

    This will work (example)

    www.shop.com.vhost
    
    www.shop.com/index.php?route=checkout/cart
    www.shop.com/checkout/cart
    
    rewrite ^/checkout/cart?$ /index.php?route=checkout/cart last;
    

    And this will not work:

    m.shop.com/checkout/cart - it will return 404.

    This will make it work

    m.shop.com.vhost
    
        location / {
    
        rewrite ^/checkout/cart?$ /index.php?route=checkout/cart last;
    
    }
    

    You just have to manually add all the SEO URLs you want. A global smart re-write would be needed for product links since of course you can't manually add them. If I may suggest something - if this is a mobile site - then you dont need SEO URLs really.. users hardly use them for phones, sure the savy user would appreciate friendly SEO links but using the PHP string and parameter and queries might be better to use on phone - the only downside is it requires advanced redirection.

    My guess is you want this to work so that you can automatically just change the header from www to m and m to www for phone so easier redirection class.. if that is the case than I would like to hear from someone else who has this done. We use NGINX on 2 load balanced servers and use Magento, OpenCart and another script for our company stores. We like you are one of the serious companies doing high volume transactions on OpenCart - we have a dedicated team handling the international orders and language queries inside it..

    评论

报告相同问题?

悬赏问题

  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号