简体   繁体   English

移动重定向和整个站点到子域

[英]Mobile redirect and full site to subdomains

After i finished the mobile version of my website i used the https://github.com/sebarmeli/JS-Redirection-Mobile-Site to make the redirection to mobile site and also the redirection to the full site. 在完成网站的移动版本后,我使用https://github.com/sebarmeli/JS-Redirection-Mobile-Site进行了重定向到移动站点以及重定向到整个站点。 Also i am using the cookie function to save the state for 1 hour using the code bellow: 我也使用cookie函数使用以下代码将状态保存1小时:

  <script>
                 SA.redirection_mobile ({
                noredirection_param : "noredirection", 
                mobile_prefix : "m", 
                cookie_hours : "1"
                });
            </script>

The problem that i have is that i use subdomains in my site and when i came back to full site if i click to a link for example news.site.com/cat1/news1 or video.site.com/video1 the redirection goes back to mobile site because cookie is created for www.site.com site the redirection is www.site.com/noredirection=true. 我遇到的问题是,我在自己的站点中使用子域,并且如果我单击完整的站点(例如,单击news.site.com/cat1/news1或video.site.com/video1的链接),则重定向返回到移动网站,因为为www.site.com网站创建了cookie,重定向为www.site.com/noredirection=true。

Any idea how to solve this? 任何想法如何解决这个问题?

The issue is pretty easy to fix if you set the cookie yourself without the www. 如果您自己设置没有www的cookie,则很容易解决该问题。 Setting the domain for the cookie as .site.com would allow for any subdomain. 将Cookie的域设置为.site.com将允许任何子域。 Take a look at this stack answer. 看看这个堆栈答案。 You might be able to modify the script your using, or just setting the cookie manually. 您也许可以修改您使用的脚本,或者只是手动设置cookie。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM