Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a problem which I'm sure it's not really hard but I really don't know how to use the Windows IIS console. I have two static html pages (Lorem Ippsum pages) which I want to access when i access my website, something like www.mysite.com/lorem1 and www.mysite.com/lorem2. Because there are a lot of deploys done on the site I don't want to put the pages in wwwroot because they will get erased at the next build. I also don't want to integrate the pages so they come with the build because it's just for testing, so i created a virtual directory virtdir where the html pages are now located, and for accessing i have to write www.mysite.com/virtdir/lorem1. The thing I'm interested in is: How can I redirect the request www.mysite.com/lorem1 to www.mysite.com/virtdir/lorem1 so as to keep the virtual directory I created and to make it invisible from the browser.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

Two ways depending on what you want:

  1. HTTP Redirect will take all /lorem1 and then send you to /virtualdir/lorem1. This is easy and you just need to make a folder in root called lorem1 and then set HTTP Redirect for it in IIS (click folder then see the HTTP Redirect icon on right). Negative is user will see it as /virtualdir/lorem1 URL once browser finishes loading.

  2. Use URL Rewrite to mask the real URL so users see it as /lorem1. Requires a IIS Microsoft add-on and a little configuration. http://www.iis.net/download/urlrewrite

share|improve this answer
    
Thank you, this is what I was looking for. I found the module and I have installed (URL Rewrite) and configured two rules like .*lorem1 -> http://www.mysite/virtdir/lorem1 and .*lorem2 -> http://www.mysite/virtdir/lorem2 but out of the two only one seems to work. the patterns are ok because i've tested them. –  primero Aug 3 '12 at 14:41

You cannot have multiple web sites pointing to the same domain, IIS won't be able to route them properly, at least no easily.

The better question is, if you have a website already setup for www.mysite.com why can't you just leave the test pages in the root directory. There is no reason why the main website has to be in the wwwroot folder either. You can always change where the Default Website points or create other websites and disable the default.

Either way if you want the files to appear in that directory.... put them in that directory. Otherwise you will have to do what you have setup so far to put them in a virtual directory and then browse to another path.

Of course if they are just static pages for testing why does using a virtual directory cause a problem? If the purpose is to make sure the site is running the static HTML files really don't matter anyway, especially if your actual site is ASP.NET based.

share|improve this answer
    
The html pages will be accesed from different locations to determine which is the shortest path. The script that accesses them will try www.mysite.com/lorem1 but the URL is www.mysite.com/virtdir/lorem1, so they will not be visible, and that is the problem. If I put them in the root directory they will get erased at the next deploy, and I don't want to to keep copying the at each deploy. I could go with puppet and ensure that thy are there but I wanted a re-write if possible. –  primero Aug 1 '12 at 14:10
    
Still don't understand what the purpose of the files are. Shortest path to what? –  Brent Pabst Aug 1 '12 at 14:11
    
I can't really explain it. Look at it this way. Let's say i have a server which handles the redirects (a HAProxy server) which redirects me to the closest proxy to me(i am the user that accesses the site in this example) and from there i continue talking only to that proxy, not the main server(the one that redirected me). But this is beside the question. –  primero Aug 1 '12 at 14:21
    
No its exactly the question. You're attempting to do geographical-based routing to the server, right? Why would you ever need to use an HTML page for this as opposed to using geo-DNS based services? –  Brent Pabst Aug 1 '12 at 14:24
    
My task is to rewrite the URL's or any action that ensures the transparency but I can't change the mechanism used behind. –  primero Aug 3 '12 at 14:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.