Magento的重定向到基于在multistores招cookie的另一个子域 [英] magento redirects to another subdomain based on cookie in multistores trick

查看:137
本文介绍了Magento的重定向到基于在multistores招cookie的另一个子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有个Magento商店,但现在决定增加其他商店分开的库存,也有一个干净的目录中,所以我决定创建商店和托管他们的子域名如 electronics.mydomain.com sport.mydomain.com 。我跟着这个教程 http://www.crucialwebhost.com/博客/如何到设置 - 多Magento的-店/ 之后却子域仍然重定向到主域名一样www.mydomain.com,即使我和我的.htaccess做什么,我发现办法去了解它在我的子域目录中打开index.php文件并加入 $ _ GET ['___店'] =STORE code; ,并在我的管理面板我输入.mydomain.com Cookie中的字段,还延长了期限为1天。

I have a magento store but currently decided to add other stores to separate the inventory and also have a clean catalog so i decided to create stores and host them on sub-domains like electronics.mydomain.com and sport.mydomain.com. i followed this tutorial http://www.crucialwebhost.com/blog/how-to-setup-multiple-magento-stores/ but after it the sub-domains were still redirecting to main domain like www.mydomain.com even though i had done nothing with my .htaccess, i found a way to go about it by opening the index.php in my subdomain directory and adding $_GET['___store']= "STORECODE"; and also in my admin panel i typed .mydomain.com in the cookie field and also prolonged the duration to 1 day.

瞧.. 一切工作现在完全直到我意识到有问题,每当我访问任何我的店(这是安装在子域),然后对尝试打开我的主域是 www.mydomain.com ,它重定向到 subdomain.mydomain.com (这是最后的网址子域我检查),但是它清除饼干后再次工作时,我意识到的问题是,Magento的是节省cookie中的当前存储ID所以,当我打开我的主域和cookie被读取,该商店将返回,因此重定向。  好了,现在我已经能够从URL中删除SID和一切工作,因为它们共享相同的Cookie域,现在我发现,如果我访问像welspot.com?_store=default我的链接,主要网站打开不重定向到子域,我希望那么,任何人都可以帮助我在我的主域的所有传入的请求重定向到mydomain.com?的_Store =默认。

Voila.. everything is working now perfectly until i realized there was a problem, whenever i visit any of my stores(which is installed on the subdomain) and then try to open my main domain that is the www.mydomain.com, it redirects to subdomain.mydomain.com(which is the url of the last subdomain i checked) but then it works again after clearing cookies, i realized the problem is that magento is saving the current store id in the cookie so when i opens my main domain and the cookie is read, that store is returned and therefore the redirect. Okay , now i have been able to remove the SID from the url and everything works as they share the same cookie domain, now i noticed if i accessed my link like welspot.com?_store=default, the main site opens without a redirect to the subdomain, i was hoping then that anybody could help me redirect all incoming requests under my main domain to mydomain.com?_store=default.

由于我还有饼干重定向的问题,我有硬codeD $ _ GET ['商店'] =默认; 进入我的指数。当先主Magento的安装PHP文件,现在一切工作的权利,但还有另外一个问题,当我去的类别字段,我尽量选择任何类别也没有选择,它只是显示创建新的品类,而不是选择和编辑点击类别,我认为这是与加入 $ _ GET ['商店'] =默认; 在我的index.php,因为当我将其删除一切正常,但是当我删除它,然后访问我的网站作为welspot.com,根据最近的子域我访问重定向那里,我认真地需要解决这个问题。

As i still have the problem of cookie redirect, i have hard-coded $_GET['store']="default"; into my index.php file at the head in the main magento installation and now everything works right but there is another problem, when i go to the categories field and i try to select any categories it doesn't select, it just displays create new category instead of selecting and editing the click category and i think it has something to do with adding $_GET['store']="default"; in my index.php because when i remove it everything works but when i remove it and visit my site as welspot.com, based on the recent subdomain i visited it redirects there and i seriously need to solve this problem.

推荐答案

而不是编辑在每家商店的index.php文件(这是一个维护麻烦),我会做的是使用说明的虚拟主机或htaccess的解决方案在此博客文章设置包含独特的商店codeS每个商店的环境变量。在nutsell添加行

Rather than editing the index.php on each store (which is a maintenance hassle), what I'd do is use the Virtual Host or .htaccess solutions described in this blog post to set an environment variable containing the unique store codes for each store. In a nutsell add the lines

SetEnv MAGE_RUN_CODE "base" # put here your website or store code
SetEnv MAGE_RUN_TYPE "website" # put here 'website' or 'store'

进入你的虚拟主机,或:

Into your virtual host, or:

SetEnvIf Host electronics.mydomain.com MAGE_RUN_CODE="base";
SetEnvIf Host electronics.mydomain.com MAGE_RUN_TYPE="website";

到你的.htaccess。确保你也这样做的主要领域,以及,设置默认存储code。

into your .htaccess. Make sure you also do this on the main domain as well, to set the default store code.

此外登录到后台,并进入系统>配置。而选择网络选项,在这里你会看到的安全与不安全的网址为您的网站。现在,请从当前配置范围下拉列表左上角的每个存储和修改URL来匹配你有设置虚拟主机(取消选中使用默认值框,然后输入新的网址)。这应该阻止你所看到的重定向,如Magento的是现在知道每家店的独特的子域。

Also log into the back end, and go to System > Configuration. And select the "Web" option, where you'll see the Secure and Unsecure URLs for your site. Now select each store from the "Current Configuration Scope" dropdown at the top left and change the URLs to match the virtual hosts you've got set up (untick the "Use Default" box and enter the new url). This should stop the redirection you're seeing, as Magento is now aware of each store's unique subdomain.

这篇关于Magento的重定向到基于在multistores招cookie的另一个子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆