Change http statuscode for umbracoUrlAlias Options
Tom
Posted: Tuesday, November 18, 2008 4:20:51 PM

Rank: Newbie

Joined: 6/28/2008
Posts: 14
Location: The Netherlands
Hi,

We are using the property field umbracoUrlAlias to redirect urls from the old site to the new one.
Example:
Old site url:
/news/this_is_the_title_of_an_article_in_the_old_site.aspx

New umbraco url:
/news/new-article.aspx

In /news/new-article.aspx i have created a property umbracoUrlAlias with the value of "news/this_is_the_title_of_an_article_in_the_old_site" so the old url will go to the new page.
Everything works fine except that it will return a http 200 status code on the old url but this must be an 301 redirect so we can prevent duplicatie content in Google.
Any ideas to change the http statuscode returned by using the umbracoUrlAlias property?
Thanks in advance!
drobar
Posted: Tuesday, November 18, 2008 4:23:35 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,831
Location: MA, USA
I'd have to check, but if you use the umbracoRedirect alias instead of umbracoUrlAlias I think you'll get the 301 response as well as the redirect.

cheers,
doug.

MVP 2007-2009 - Percipient Studios
mortenbock
Posted: Tuesday, November 18, 2008 6:22:20 PM

Rank: Addict

Joined: 7/19/2006
Posts: 815
Location: Århus, Denmark
But using the umbracoRedirect would demand that you create umbraco pages with the old url's which I am guessing you do not want to do?

How many articles are we talking about? Would it be ok to make a manual list of the needed redirects in an xml file?

Morten Bock - Level 2 certified - MVP 2008/2009 - My danish blog with a few english posts

mortenbock
Posted: Tuesday, November 18, 2008 6:26:55 PM

Rank: Addict

Joined: 7/19/2006
Posts: 815
Location: Århus, Denmark
You could use the UrlRewriting.config file to manually edit a list urls to redirect, like this:

Code:

<add name="htmrewrite"
            virtualUrl="^~/news/this_is_the_title_of_an_article_in_the_old_site.aspx"
            rewriteUrlParameter="ExcludeFromClientQueryString"
            destinationUrl="~/news/new-article.aspx"
            redirectMode="Permanent"
            redirect="Application"
            ignoreCase="true" />
<add name="htmrewrite"
            virtualUrl="^~/news/this_is_the_title_of_an_article_in_the_old_site2.aspx"
            rewriteUrlParameter="ExcludeFromClientQueryString"
            destinationUrl="~/news/new-article2.aspx"
            redirectMode="Permanent"
            redirect="Application"
            ignoreCase="true" />


Morten Bock - Level 2 certified - MVP 2008/2009 - My danish blog with a few english posts

mortenbock
Posted: Tuesday, November 18, 2008 6:28:41 PM

Rank: Addict

Joined: 7/19/2006
Posts: 815
Location: Århus, Denmark
Alternatively you could place a usercontrol on your template, that checks if the current page has been fetched with the correct url, and if not, do a 301 redirect the the umbraco.library.NiceUrl() url.

Morten Bock - Level 2 certified - MVP 2008/2009 - My danish blog with a few english posts

drobar
Posted: Tuesday, November 18, 2008 6:32:59 PM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,831
Location: MA, USA
Good point, Morten! I wonder what happens if you have both umbracoUrlAlias and umbracoRedirect. Hmmm. Might work. Worth a quick test at least.

Otherwise, you could use one of the various redirect packages from Casey or Soeren, for instance to handle the redirection aspect.

Beyond that, I think Morten is right in asking about an xml file or urlRewriting or some other options.

cheers,
doug.

MVP 2007-2009 - Percipient Studios
Tom
Posted: Wednesday, November 19, 2008 9:20:38 AM

Rank: Newbie

Joined: 6/28/2008
Posts: 14
Location: The Netherlands
Hi guys,

Thank you for your quick reply's!

Mortenbock is right. I don't want to create the "old" pages in Umbraco.
There are +/- 200 old url's i can add them manually in the UrlRewriting.config but i want to make the old url redirects easy editable because new documents (and urls) are added to the current system. I think when i use the umbracoUrlAlias and the umbracoRedirect on the same page it will always redirect with a 301, i only need a redirect when accessing the page by the old url defined in the umbracoUrlAlias property. Antoher side effect is that how do i automatically fill the umbracoRedirect property with the nodeid from the current page?

I think the option from mortenbock is the best option to define the property umbracoUrlAlias for each document type and create a usercontrol that checks if the current page has been fetched with the correct url, and if not, do a 301 redirect the the umbraco.library.NiceUrl() url.

The redirect packages are working the other way around, redirecting from a umbraco page to an internal of external url. So this is not an option i think.
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.