Is it possible to do something similar to server.transfer , but to automatically apply it to all files in one subdirectory and transfer them to the same structure in another directory, without the user seeing any change in the URL.
e.g. if I have the files:
\sub1\page1.aspx
\sub1\page2.aspx
Then anybody requesting:
\sub2\page1.aspx or
\sub3\page1.aspx
will be transferred to \sub1\page1.aspx without their URL changing. I'd also like to know what the URL is the user made the request from, for example with HttpContext.Current.Request.Url, preserver querystrings etc. as is the case for server.transfer
My list of alternative subdirectories is defined, so I don't mind creating a folder for each on the server and putting a web.config file in it or similar to create the rules. What I would rather not do is recreate the entire structure of pages in each subfolder
using pages with the same name but with a server.transfer to sub1 in each - though that is my fall-back position if there is no better option.
Maybe using URL Rewrite module? Any suggestions appreciated.
wjb21
0 Points
3 Posts
rewrite requests from one subdirectory to another
Apr 23, 2012 10:15 AM|LINK
Is it possible to do something similar to server.transfer , but to automatically apply it to all files in one subdirectory and transfer them to the same structure in another directory, without the user seeing any change in the URL.
e.g. if I have the files:
\sub1\page1.aspx
\sub1\page2.aspx
Then anybody requesting:
\sub2\page1.aspx or
\sub3\page1.aspx
will be transferred to \sub1\page1.aspx without their URL changing. I'd also like to know what the URL is the user made the request from, for example with HttpContext.Current.Request.Url, preserver querystrings etc. as is the case for server.transfer
My list of alternative subdirectories is defined, so I don't mind creating a folder for each on the server and putting a web.config file in it or similar to create the rules. What I would rather not do is recreate the entire structure of pages in each subfolder using pages with the same name but with a server.transfer to sub1 in each - though that is my fall-back position if there is no better option.
Maybe using URL Rewrite module? Any suggestions appreciated.
tusharrs
Contributor
3230 Points
668 Posts
Re: rewrite requests from one subdirectory to another
Apr 23, 2012 10:21 AM|LINK
Hi,
refer to this link
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/6b855a7a-0884-4508-ba95-079f38c77017.mspx?mfr=true
( Mark as Answer if it helps you out )
View my Blog
DarrellNorto...
All-Star
87443 Points
9718 Posts
Moderator
MVP
Re: rewrite requests from one subdirectory to another
Apr 23, 2012 10:23 AM|LINK
This URL Rewriting solution does what you want:
http://www.simple-talk.com/dotnet/asp.net/a-complete-url-rewriting-solution-for-asp.net-2.0/
Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.