Question

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,

Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top