Hey thanks for your response - really appreciate the help.
Out of interest is the umbracoRedirect making a 301 redirect?
If so this is cool for one or two pages, but looks like updating the
UrlRewriting.config might be better for a number fo pages - though the
client can't do this through the UI as far as I can tell?
umbracoRedirect is a 302, so best taking bfi's code and turning it in to a macro that goes in each page, along with a property that allows setting a redirect url. If the redirect is set, call the macro and pass in the url to redirect to. You can see another example of inline c# and calling a function from within xslt at http://our.umbraco.org/projects/change-output/general/4246-Also-possible-using-inline-script-in-xslt
I wrote a simple user control that checks an xml file of old paths and redirects to new paths/id. This can be added to a 404 page in umbraco, and is written to work with both non-ASPX pages, as well as umbraco 404 errors. (only works on 404 requests).
As for domain redirects (and even cononical issues), a control that checks for a specific domain could be used to provide those options. I have one that checks the domain against a property on my root node and redirects the request to that domain if it does not match. It also checks that the page path is an exact match of the NiceUrl generated URL (with some exceptions). This guarantees that search engines only get one instance of a page versus all the variations that may occur due to link changing..
Email me at casey at bestcasetech.com if you would like the controls.
I'm building a new version of an old htm site, that is very fragmented
So making a list of existing pages and their new counterpart,for use in urlrewrite.config in umbraco, is a pretty daunting task.
So i thought it would be easier if my client could input the url of the old page when creating the new page, and thereby tell umbraco that if for example
/credits/credits.htm is requested, it would redirect to /hello/credits.aspx
You can also use the built in URL rewriting.net that comes packaged with Umbraco.
As BarneyHall mentioned above by default you cannot edit the config files through the UI, but, if you look in the packages section you can find a package that adds admin of the config files to the UI.
I've just posted the same example on another post, but I thought it was clearer if I cross posted it here, I hope that's ok?!
You can then add 301 ( or 302 ) re-directs, here is an example of a 301 re-direct:
And you can see this working if you open up firebug and look at the
network section and then hit the following URL, as I have just updated
my redirect using this.
I have just added a blog post about how to add intellisense to
Visual Studio when editing the urlrewriting.config file, it's not
something I realised you could do until today, so I thought it might be
useful for someone reading this thread :)
Umbraco 4.6.1: Confused. I've made the above change (tailored to my situation, of course) to conf/urlrewriting.conf, and I've used the config tree package, ensuring that I'm modifying against my live site. But the change isn't happening.
One difference between the example and my use case is I don't need to switch domains; I'm redirecting within the app. For example:
301 redirect options
Hello, can anyone offer any advice on how to best implement 301 redirects?
There seems to be a few options, but I wondered what is best practise and most practical?
Ideally a solution within the Umbraco UI (4.0.2.1) is prefered in this case.
Any pointers and advice greatly appreciated.
Thank you,
Barney
I don't know about best practice, but you can use an umbracoRedirect property, or from xslt with a C# script, e.g.
<msxsl:script language="C#" implements-prefix="redir">
<msxml:assembly name="System.Web" />
<msxml:using namespace="System.Web" />
<![CDATA[
public String Redirect(String url){
System.Web.HttpContext.Current.Response.Status = "301 Moved Permanently";
System.Web.HttpContext.Current.Response.AddHeader("Location", url.ToString());
return "";
}
]]>
</msxsl:script>
Hope this helps.
Hey thanks for your response - really appreciate the help.
Out of interest is the umbracoRedirect making a 301 redirect?
If so this is cool for one or two pages, but looks like updating the UrlRewriting.config might be better for a number fo pages - though the client can't do this through the UI as far as I can tell?
umbracoRedirect is a 302, so best taking bfi's code and turning it in to a macro that goes in each page, along with a property that allows setting a redirect url. If the redirect is set, call the macro and pass in the url to redirect to. You can see another example of inline c# and calling a function from within xslt at http://our.umbraco.org/projects/change-output/general/4246-Also-possible-using-inline-script-in-xslt
Dan
I've just checked a page with umbracoRedirect in firebug and the http response status is 302 Found.
Thanks for your help chaps.
You could also install the URL Rewrite module for IIS and add your 301's to the Web.Config:
<rewrite>
<rules>
<rule name="Redirect non-www to www" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^CHANGE-MY-DOMAIN.TLD$" />
</conditions>
<action type="Redirect" url="http://www.CHANGE-MY-DOMAIN.TLD" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
That's usually what we do... :)
I wrote a simple user control that checks an xml file of old paths and redirects to new paths/id. This can be added to a 404 page in umbraco, and is written to work with both non-ASPX pages, as well as umbraco 404 errors. (only works on 404 requests).
As for domain redirects (and even cononical issues), a control that checks for a specific domain could be used to provide those options. I have one that checks the domain against a property on my root node and redirects the request to that domain if it does not match. It also checks that the page path is an exact match of the NiceUrl generated URL (with some exceptions). This guarantees that search engines only get one instance of a page versus all the variations that may occur due to link changing..
Email me at casey at bestcasetech.com if you would like the controls.
I'm building a new version of an old htm site, that is very fragmented
So making a list of existing pages and their new counterpart,for use in urlrewrite.config in umbraco, is a pretty daunting task.
So i thought it would be easier if my client could input the url of the old page when creating the new page, and thereby tell umbraco that if for example
/credits/credits.htm is requested, it would redirect to /hello/credits.aspx
Is there a simple way to do this?
Hi All,
You can also use the built in URL rewriting.net that comes packaged with Umbraco.
As BarneyHall mentioned above by default you cannot edit the config files through the UI, but, if you look in the packages section you can find a package that adds admin of the config files to the UI.
I've just posted the same example on another post, but I thought it was clearer if I cross posted it here, I hope that's ok?!
You can then add 301 ( or 302 ) re-directs, here is an example of a 301 re-direct:
And you can see this working if you open up firebug and look at the network section and then hit the following URL, as I have just updated my redirect using this.
http://www.nursingpersonnel.co.uk
Should 301 re-direct to:
http://www.nursing-personnel.co.uk
Cheers,
Chris
I have just added a blog post about how to add intellisense to Visual Studio when editing the urlrewriting.config file, it's not something I realised you could do until today, so I thought it might be useful for someone reading this thread :)
Adding Intellisense for editing the urlrewriting.config file
Cheers,
Chris
Umbraco 4.6.1: Confused. I've made the above change (tailored to my situation, of course) to conf/urlrewriting.conf, and I've used the config tree package, ensuring that I'm modifying against my live site. But the change isn't happening.
One difference between the example and my use case is I don't need to switch domains; I'm redirecting within the app. For example:
<urlrewritingnet xmlns="http://www.urlrewriting.net/schemas/config/2006/07">
<rewrites>
<add name="301_Redirects_for_Articles"
redirectMode="Permanent"
redirect="Domain"
ignoreCase="true"
rewriteUrlParameter="IncludeQueryStringForRewrite"
virtualUrl="http://customsite.com/articles/articles/(.*)"
destinationUrl="http://customsite.com/articles/$1" />
</rewrites>
</urlrewritingnet>
What's the best way to troubleshoot this?
is working on a reply...