Grails重定向问题与域名更改 [英] Grails Redirect Issue with Domain Name Changing

查看:150
本文介绍了Grails重定向问题与域名更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我运行了一个Grails应用程序,例如: www.mysite.com



Config.groovy 我有我的 grails.serverURL 设置为 www.mysite.com $ b

我使用重定向方法重定向到某个特定的方法,但它总是建立url使用 grails.serverURL 值,而不是从用户的实际URL中构建。当有人在 mysite.com 访问该网站时,遇到问题,将 www 关闭。然后,当他们点击导致重定向的链接时,它们被转发到 www.mysite.com ,这使他们失去了会话。我应该做什么不同?

解决方案

您使用什么网络服务器来托管该网站?



<通常,作为一个经验法则,我总是配置Apache以确保任何非www。呼叫被重定向到www。等价。



Apache配置或.htaccess中的两行代码都是必需的,例如

  RewriteCond%{HTTP_HOST} ^ exampledomain\.co\.uk $ [NC] 
RewriteRule ^(。*)$ http://www.exampledomain.co.uk$1 [R = 301,L]


I have a Grails application running on, let's say: www.mysite.com

In Config.groovy I have my grails.serverURL set to www.mysite.com

I use the redirect method to redirect to a certain method, but it always builds up the url using the grails.serverURL value, instead of building from the actual URL of the user. I run into a problem when someone visits the site at mysite.com, leaving off the www. Then, when they click the link that causes the redirect, they are forwarded to www.mysite.com which makes them lose their session. What should I be doing differently? Thanks!

解决方案

What webserver are you using to host the site?

Generally as a rule of thumb I always configure Apache to ensure any non www. calls are redirected to the www. equivalent.

Two lines in the Apache config or a .htaccess is all that is needed, e.g.

RewriteCond %{HTTP_HOST} ^exampledomain\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://www.exampledomain.co.uk$1 [R=301,L] 

这篇关于Grails重定向问题与域名更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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