【问题标题】:Redirect No-WWW to WWW with Intelligencia.UrlRewriter使用 Intelligencia.UrlRewriter 将 No-WWW 重定向到 WWW
【发布时间】:2014-01-20 21:43:51
【问题描述】:

我有一个 ASP.Net 网站,我在其中使用模块 Intelligencia.UrlRewriter (urlrewriter.net)。我在使用它将无 www 重定向到 www 时遇到问题,以避免搜索引擎将这两个网址作为两个不同的网站处理。

我尝试了以下方法:

<redirect url="http://thetotalsite\.it(.+)" to="http://www.thetotalsite.it$1" />

但它不起作用,或者更好的是,它“有时”起作用。 例如,如果我尝试达到: http://thetotalsite.it 它重定向到 www.thetotalsite.it

相反,如果我在主机名后面有一些东西,例如: http://thetotalsite.it/a/article-nice-name

它不会重定向。

怎么会?

(N.d.:我使用以下规则来处理文章的 url 重写:

<rewrite url="/a/(.+)$" to="/articoli/showarticle.aspx?c=$1"/>

)

提前致谢,

【问题讨论】:

    标签: asp.net redirect url-rewriting urlrewriter.net


    【解决方案1】:

    显然,我使用在另一个 stackoverflow 问题中找到的以下内容解决了:

        <!-- Ensure that all are on the same top domain and sub domain. -->
    <unless header="HTTP_HOST" match="www.thetotalsite.it">
        <redirect 
            url="^(.*)$" 
            to="http://www.thetotalsite.it$1" 
            processing="stop" />
    </unless>
    

    请注意,如果您的 UrlRewriter.Net 版本过时,它将无法使用。下载并编译最新的源代码 (2.0.0.9)。

    【讨论】:

      猜你喜欢
      • 2018-02-16
      • 1970-01-01
      • 2011-01-05
      • 2016-06-28
      • 2012-10-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多