我有一个ASP.Net网站,在其中我使用模块Intelligencia.UrlRewriter (urlrewriter.net)。我在使用它重定向到www,以避免搜索引擎将这两个urls作为两个不同的网站处理时遇到了问题。
我尝试了以下几点:
<redirect url="http://thetotalsite\.it(.+)" to="http://www.thetotalsite.it$1" />但它不起作用,或者更好的是,它“有时”起作用。例如,如果我试图到达:http://thetotalsite.it,它将重定向到www.thetotalsite.it
相反,如果我的主机名后面有什么东西,例如:http://thetotalsite.it/a/article-nice-name
它不会重定向。
怎么会这样?
(注:我使用以下规则处理文章的url重写:
<rewrite url="/a/(.+)$" to="/articoli/showarticle.aspx?c=$1"/>)
提前谢谢你,
发布于 2014-01-20 22:00:33
显然,我是通过在另一个堆栈溢出问题上发现的如下方法解决的:
<!-- 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)。
https://stackoverflow.com/questions/21244761
复制相似问题