문제

I've an ASP.Net website, in which I use the module Intelligencia.UrlRewriter (urlrewriter.net). I'm having problems using it to redirect a no-www to www, to avoid search engines handle the two urls as two different websites.

I tried the following:

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

But it doesn't work, or better, it works "sometimes". For example, if I try to reach: http://thetotalsite.it It redirects to www.thetotalsite.it

Instead, if I had something that follows the hostname, for example: http://thetotalsite.it/a/article-nice-name

It doesn't redirect.

How come?

(N.d.: I use the following rule to handle the url rewrite for articles:

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

)

Thanks in advance,

도움이 되었습니까?

해결책

Apparently, I solved using the follows I found on another stackoverflow question:

    <!-- 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>

Note that if you have an outdated version of UrlRewriter.Net, it won't work. Download and compile the latest sources (2.0.0.9).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top