Question

In Umbraco, I use the umbracoRedirect alias to create a 302 redirect, using a content picker datatype to select the destination page. So for example, if I went to domain.com, it could redirect to domain.com/home.aspx.

However, I'm trying to figure out how to do this with a permanent, 301 redirect but I'm having no luck whatsoever. I edited the UrlRewriting file in the config folder using the example in the file:

<add name="urlrewrite" 
    virtualUrl="^~/" 
    rewriteUrlParameter="ExcludeFromClientQueryString" 
    destinationUrl="~/home.aspx" 
    ignoreCase="true" />

This does indeed redirect domain.com to domain.com/home using a 301, but every other page is 404'd. What's the easiest way to 301 redirect the top level page to /home.aspx?

Was it helpful?

Solution 3

For those with the same problem, I finally got this to work how I wanted with the following entry in the UrlRewriting config file (notice the added regex to the virtualUrl attribute):

<add name="urlrewrite" 
     virtualUrl="^/(\?|$)" 
     rewriteUrlParameter="ExcludeFromClientQueryString" 
     destinationUrl="~/home.aspx" 
     ignoreCase="true" />

OTHER TIPS

change the virtualUrl in (remove the ^)

~/  

or in

^/$ 

^ is regex for "start of the string", while $ means end of the string.

You should use root(default start node) node as redirect document type:

You should have a look at this discussion

http://our.umbraco.org/forum/using/ui-questions/5255-301-redirect-options

and

http://our.umbraco.org/wiki/reference/umbraco-best-practices/umbracoredirect

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