11

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;
    }
}
HumbleLearner
  • 103
  • 2
  • 9
TheBlackBenzKid
  • 26,324
  • 41
  • 139
  • 209
  • 1
    If I'm not mistaken, these setups look exactly the same. Why don't you just use one `server {...}` section and add `m.shop.com` to the `server_name` directive? As for your error itself, from the top of my head I have only a far-off guess: is your `m.shop.com` config really active? They're sometimes organized in one directory with the config files themselves, and one where you're supposed to put a symlink to it. The link is there, right? – Carsten May 07 '13 at 17:14
  • The link is there.. the site works.. the m.shop.com site works and it shows the other OpenCart store - the SEO URLs do not work however. – TheBlackBenzKid May 08 '13 at 07:47
  • I do not have experience with Open Cart, however, I'm curious if you have to do this through nginx? If not can't you just modify the .htaccess file and use a mod rewrite. Here is an example I found with a single store [Example](http://www.templatemonster.com/help/files/OpenCart/opencart_seo_urls.htm). Maybe it will be helpful. – Dropzilla Jun 18 '13 at 16:58

2 Answers2

8

I got this article and details from someone, in my company SEO and marketing team are using this tool..

From Setup SEO Full Friendly URLs on nginx on the XenForo forums:

It's actually really really simple.

Considering you have uploaded XenForo into the directory "community", just add this to your nginx config:

location /community/ {
            index  index.php index.html index.htm;
            try_files  $uri $uri/ /community/index.php?$uri&$args;
        }

While you are at it you might also want to add this to block external access to the folders "internal_data" and "library".

location ~ ^/community/(internal_data|library)/(.*)$ {
            internal;
        }

Restart nginx and enable Full Friendly URLs.

From Straight Forward Easy Instructions for Multi-Store Setup? on the Opencart forums:

The short version is:
create 2 demo sub domains
subA.domain.com
subB.domain.com
and "point" both sub domains to the same folder on your web host.
i.e. public_html/shop
Install opencart to the first sub domain and then go through the admin and add an extra store.

So you'll have Shop1 subA.domain.com and Shop2 subB.domain.com both running the same code.

Hope that makes sense.

Community
  • 1
  • 1
Javascript Coder
  • 5,691
  • 8
  • 52
  • 98
0

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..

M1th
  • 621
  • 1
  • 7
  • 11