1

I have been struggling to get Umbraco (7.1.4) to prefix URLs without www with www. I can't quite grasp the syntax of UrlRewriting.Net.

My current solution is:

<add name="forcewww http" 
    virtualUrl="http\://(?!www\.)" 
    redirectMode="Permanent" 
    destinationUrl="http://www." 
    ignoreCase="true" 
    redirect="Domain" /> 

But I would like it not to trigger for URLs for the Umbraco backend (containing /umbraco). Something like (\/umbraco|\/data|\/install|\/usercontrols|\/umbraco_client)).

The solution should be valid for multiple domains/tlds.

Your help is much appreciated!

thilemann
  • 397
  • 4
  • 16

1 Answers1

2

We use this syntax in the urlReWriting.config:

<add name="SEOfixMyExampleDomain" 
     virtualUrl="^http\://example.com/(.*)"
     rewriteUrlParameter="ExcludeFromClientQueryString"
     destinationUrl="http://www.example.com/$1"
     redirect="Domain"
     redirectMode="Permanent"
     ignoreCase="true" />

The (.*) is translated into the $1 on the destination domain. If you would like to have it cross domain you could replace the domain by a wildcard match. But I would not do that. For every domain we configure in umbraco, we add a new line in the UrlRewriting.config. Works fast and flawless. Easy to maintain of someone decides to have a reverse (non-wwww default) on one domain.

We also redirect for the umbraco specific URLS because:

  • /install should be removed after deployment
  • /usercontrols is not called on the browser
  • /data is not used by any recent package
  • /umbraco and /umbraco_client : why not

Apart from that we noticed that canonical URLs also help in indexing the correct domain...

dampee
  • 3,392
  • 1
  • 21
  • 37