views:

139

answers:

2

Hopefully a simple question although one I have found impossible to answer myself using the Googles!

I have a website on IIS with the URL http://www.contoso.com/ which points to C:\www\public\

There has been a forced directory restructure so now all of the data (Default.aspx, Product.aspx, etc.) that originally resided in C:\www\public\ now resides in C:\www\public\en\ie\ - however, the IIS website document root is still C:\www\public\

So, essentially, I have a lot of inbound links to http://www.contoso.com/Product.aspx?id=1 (etc.) which are now returning 404 errors - the correct link is now http://www.contoso.com/en/ie/Product.aspx?id=1

Please consider that I can make no changes to the directory structure or the IIS document root... so I must solve this issue using URL rewriting.

Is it possible to capture all requests to contoso.com/* and rewrite them to contoso.com/en/ie/* ??

A: 

Change the root directory of your website from C:\www\public\ to C:\www\public\en\ie\ and everything should be fine.

If you cannot do this for any reason, make a custom 404 page and rewrite to url in there and redirect with a 301

See: http://searchengineland.com/url-rewriting-custom-error-pages-in-aspnet-20-12234

Ivo
Please consider that I can make no changes to the directory structure or the IIS document root... so I must solve this issue using URL rewriting.Files exist above the /en/ie/ dir level that are still served via HTTP.
Rob Burke
it's an IIS setting for your website only
Ivo
I must re-iterate that I *cannot* make any modifications to IIS other than URL re-writing. I wish I could but in the current situation I can't. I know it's not perfect but it is what it is. Wouldn't the custom 404 page with a 301 redirect cause an infinite loop on genuine 404 errors?
Rob Burke
for every url you recieve you check if "en/ie/" is in there, if not redirect to "en/ie/pagename.aspx" so if you get a 404 on as "en/ie/" page it will be handled as a 404 and not redirected
Ivo
A: 

As Ivo suggests, using url rewriting you can set up inbound rules that match the old url pattern and redirect to the new pattern

http://learn.iis.net/page.aspx/460/using-url-rewrite-module/

Phil Hale