1


Magento 上有一家商店 - site.com。还有一个关于子域的商店视图,例如 sub1.site.com、sub2.site.com、sub3.site.com。一切正常,但按位设置的主题不适用于子域。Theme 使用 Mage::getUrl() 生成 AJAX 快速查看和添加到购物车的 URL。它使用商店的基本 URL。
从主站点 site.com 一切正常,预览 AJAX 工作正常。在子域上不起作用,因为形成子域 sub1.site.com/catalog/ajax_product/view 的基本 URL,但必须是 site.com/catalog/ajax_product/view 的形式。在子域上的 Htaccess 中的重定向,例如:

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/(catalog/ajax_product/.*|checkout/cart/add/.*)$
RewriteRule ^(.*)$ http://site.com/$1/ [R=301,L]

不工作!

帮助!

4

1 回答 1

0

I'm not sure if your application configuration is correct. In my opinion you don't need to make redirection with .htaccess. So here are couple of checkpoints:

1) Check that you have set a correct Base secure and unsecure URLs in Back Office (Admin Panel) for each store view (subdomain)

System > Configuration > Web > (Un)secure > Base Url

By default there should be http://store.com, and for each website (regarding Magento scope) URL should be different.

2) Cookie domain must be set for each store view respectively.

System > Configuration > Web > Session Cookie Management > Cookie Domain

For the default store you can leave it empty, but you must fill it for others, e.g. .sub1.store.com, .sub2.store.com, etc. Note that dot ('.') at the beginning is mandatory.

3) Set Apache vhosts for each domain.

You should have separate entries for site.com, sub1.site.com, etc in your vhosts configuration.

Now you can define which store view to load based on the domain. You can do this in 3 ways:

  • .htaccess
  • modify index.php of application
  • set proper Env variable directly in vhost

In this post you can find each mentioned solution.

While dealing with multiple store views and domains with Magento it is all about to load a proper store code in Mage::run() method.

Here's an example for .htaccess solution:

SetEnvIf Host .*sub1.site.com.* MAGE_RUN_CODE="sub1"
SetEnvIf Host .*sub2.site.com.* MAGE_RUN_CODE="sub2"

Don't forget to flush cache and perform reindex of all entities after you set is all correct.

于 2013-04-04T10:20:59.853 回答