I have some trouble with url rewriting / 301 redirects. The client has got around 1650 rewrites from their old page to their new page. These urls often ends with .html and a lot of other extensions rather than .aspx. I managed to get the UrlRewrite.config file running with all 1650 rules which actually made the redirects. However, the server went to 100% cpu load because of this :-/ I guess it's because of the amount of rules?
Is there any other way to achieve this? I have tried with global.asax and a 404 handler, but when I enter an URL with an extension that is not .aspx, the iis gives a 404 not found page.
Out of interest do you really need 1650 rules? Is there any kind of pattern to the redirect?
An alternative is to write a NotFoundHandler implementing the umbraco.interfaces.INotFoundHandler interface method and adding it to the list of NotFoundHandlers specified in the 404handlers.config. We have implemented something like this that references a cached key/value list of redirects and forwards if one is found.
I would suggest the something along the lines of what Stephen suggested.
Either try and use the IIS Url Rewrite module. If thats not an option, I think you should be able to force IIS to serve .html extension through to the .NET pipeline via settings in the web.config. I would probably write a HttpModule and register it in the 404handlers.config.
Is that enough to start on ? Let me know if you need help setting any of this up.
Only downside of this (at least when you haven't got access to the webserver) is that your rewritemaps.config file must not exceed the filesize of 250kb! Which lead to leavinging some (actually a lot) urls out for now.
This leaves me with the following question. Using the web.config rewriter, is there any way to make a general redirect rule to save some size in the rewritemaps.config? In this particular case I have a *lot* of urls looking like this:
URL Rewrite issue
Hi all,
I have some trouble with url rewriting / 301 redirects. The client has got around 1650 rewrites from their old page to their new page. These urls often ends with .html and a lot of other extensions rather than .aspx. I managed to get the UrlRewrite.config file running with all 1650 rules which actually made the redirects. However, the server went to 100% cpu load because of this :-/ I guess it's because of the amount of rules?
Is there any other way to achieve this? I have tried with global.asax and a 404 handler, but when I enter an URL with an extension that is not .aspx, the iis gives a 404 not found page.
Anyone got a hint/suggestion on this one?
Thanks a lot in advance.
- Bo
Running on which version of IIS? If IIS7 or more, I'd suggest using the build-in rewriting module + static rewrite map.
Hi Stephen,
Yep, it is IIS7 :-) But isn't the build in rewriting module on the iis the same as when you enter URLs in the UrlRewrite config?
I have no clue about what a static rewrite map is ;-) Have to read up on that.
Thanks!
Out of interest do you really need 1650 rules? Is there any kind of pattern to the redirect?
An alternative is to write a NotFoundHandler implementing the umbraco.interfaces.INotFoundHandler interface method and adding it to the list of NotFoundHandlers specified in the 404handlers.config. We have implemented something like this that references a cached key/value list of redirects and forwards if one is found.
Low practical:
How about making a rewrite that sends *.html to /myhandler.aspx?oldurl=$1, which will then 302 redirect to whatever new location it should go to?
No, the IIS Url Rewrite module (http://www.iis.net/downloads/microsoft/url-rewrite) and the build in rewrite stuff in Umbraco are NOT the same.
The build-in Umbraco rewrite functionallity is built upon http://www.urlrewriting.net and it is known for scaling very poorly.
I would suggest the something along the lines of what Stephen suggested.
Either try and use the IIS Url Rewrite module. If thats not an option, I think you should be able to force IIS to serve .html extension through to the .NET pipeline via settings in the web.config. I would probably write a HttpModule and register it in the 404handlers.config.
Is that enough to start on ? Let me know if you need help setting any of this up.
Kind regards
Mads
Hi all,
Sorry for the late response here. It's been three hours of pure stress :-)
I went for the web.config url rewriter with a rewrite map as config source which works like it should.
The web.config looks like this:
This goes in the <system.webServer> snippet.
My rewritemaps.config then looks like this:
Only downside of this (at least when you haven't got access to the webserver) is that your rewritemaps.config file must not exceed the filesize of 250kb! Which lead to leavinging some (actually a lot) urls out for now.
This leaves me with the following question. Using the web.config rewriter, is there any way to make a general redirect rule to save some size in the rewritemaps.config? In this particular case I have a *lot* of urls looking like this:
The above urls all point to the same page: www.mynewsite.com/mynewpage1.aspx
Thanks again! All of your help and hints are greatly appreciated :-)
All the best,
Bo
Then maybe you can have one non-static rule matching /subpage1/subpage2/(.*) and redirecting to /subpage1/subpage2/mynewpage1.aspx.
is working on a reply...