简体   繁体   中英

Umbraco rewrite rule for non-www domains

I'm trying to redirect any non-www prefixed traffic to the www prefixed domain. I'm using Umbraco as the CMS and have added the following code into the urlrewritingnet config file:

<add name="nonWWW" 
                virtualUrl="^(?!www\.)(.*)$" 
                rewriteUrlParameter="ExcludeFromClientQueryString" 
                destinationUrl="http://www.domain.co.uk$1" 
                ignoreCase="true" />

I'm getting a "is not a valid virtual path" error

This seems to be working:

<add name="nonWWW"
                redirectMode="Permanent"
                redirect="Domain"
                ignoreCase="true"
                rewriteUrlParameter="IncludeQueryStringForRewrite"
                virtualUrl="http://domainname.co.uk/(.*)" 
                destinationUrl="http://www.domainname.co.uk/$1" 
                 />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM