开发环境中的URLRewriteFilter?

时间:2013-07-17 15:28:01

标签: grails development-environment tuckey-urlrewrite-filter

我正在使用UrlRewriteFilter将我的域的所有请求转发到SEO的“www”版本。 我有一个基本规则:

<rule>
<name>Domain Name Check</name>
<condition name="host" operator="notequal">www.mydomain.com</condition>
<from>/.*</from>
<to type="permanent-redirect">http://www.mydomain.com</to>
</rule>

这适用于制作,但当我在开发模式下运行时,它也会更改我的域,从localhost:8080/mysitewww.mydomain.com

如何解决开发模式问题?我正在使用Grails和Tomcat,因此所有内容都捆绑在.war中,并部署到服务器上。

谢谢!

2 个答案:

答案 0 :(得分:0)

您可以尝试在BuildConfig.groovy中添加此内容以排除依赖项吗? (如果您尚未在lib

中添加jar
grails.project.dependency.resolution = {
    inherits("global") {
        if (Environment.current != Environment.PRODUCTION)
            excludes "urlrewritefilter"
    }
}

如果这不起作用,那么在我看来最安全的做法是分叉/克隆plugin(使用最新版本的urlrewritefilter:4.0.3)并通过添加UrlRewriteGrailsPlugin.groovy来修改def environments = ['prod'] //or 'production' def scopes = [excludes:'run'] //If you normally use run-app in development 以下要素:

{{1}}

并使用插件而不是添加依赖项。

答案 1 :(得分:0)

您不必排除lib。相反,您可以为开发和生产定义different web.xml files。您只需在制作中包含UrlRewriteFilter。