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

标签 php url-rewriting nginx opencart

我正在尝试让 SEO URL 在 OpenCart 中跨多个商店工作。

我在后台有两个商店

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

SEO URL 适用于 http://www.shop.com 但是他们为 http://m.shop.com 返回一个 not_found.tpl(404 页面)

但这有效:

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

明智的SEO,它应该是

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

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

我正在使用 NGINX。这是配置:

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;
    }
}

最佳答案

我从某人那里得到了这篇文章和详细信息,我公司的 SEO 和营销团队正在使用这个工具..

来自 Setup SEO Full Friendly URLs on nginx在 XenForo 论坛上:

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.

来自 Straight Forward Easy Instructions for Multi-Store Setup?在 Opencart 论坛上:

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.

希望这是有道理的。

关于php - 使用 Nginx 在 OpenCart 上的多个商店和子域上启用 SEO URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16424651/

相关文章:

symfony - HTTPS 上的网络套接字

php - sphinx表在其他基础上查表

ruby-on-rails - cucumber default_url_options[ :host] everytime "www.example.com" even if specified in environtemnts/test. rb

tomcat urlrewritefilter baseurl

node.js - ExpressJS - Elastic Beanstalk 502 错误网关

php - 配置 phabricator 和 nginx 的问题

php - 使用 Yii2 队列扩展和 Postgres 10.4 时出现错误 'Has not wait the lock'

php - 如何计算每个数组的结果

php - Ajax 返回格式化整数

http - url 重写是如何工作的?