Using IIS6, how can I place files in a sub-folder but have them served as if they were in the root?

StackOverflow https://stackoverflow.com/questions/45796

  •  09-06-2019
  •  | 
  •  

Question

Our ASP.NET 3.5 website running on IIS 6 has two teams that are adding content:

  • Development team adding code.
  • Business team adding simple web pages.

For sanity and organization, we would like for the business team to add their web pages to a sub-folder in the project:

Root: for pages of development team

Content: for pages of business team

But

We would like for users to be able to navigate to the business team content without having to append "Content" in their URLs, as described below:

Root: Default.aspx (Available at: www.oursite.com/default.aspx)

Content: Popcorn.aspx (Available at: www.oursite.com/popcorn.aspx)

Is there a way we can accomplish for making a config entry in an ISAPI rewrite tool for every one of these pages?

Was it helpful?

Solution

I don't have any way to test this right now, but I think you can use the -f flag on RewriteCond to check if a file exists, in either directory.

RewriteCond %{REQUEST_FILENAME} -!f
RewriteCond Content/%{REQUEST_FILENAME} -f
RewriteRule (.*) Content/(.*)

Something like that might do what you're after, too.

OTHER TIPS

Since the extensions will be ASPX, ASP.NET will pick up the request... you can write an HttpModule that checks for pages that yield a 404 and then check the subfolder also.

If you know that all pages with a certain format will be coming from that folder, then you can just rewrite the URL in ASP.NET (either in Global.asax or an HttpModule).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top