Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to define a virtual directory in IIS and somehow make the files in that directory relative to the physical directory and not to the virtual directory ?

For instance on my server I have the following folders: D:\WebSite\Css\myTheme.css, D:\WebSite\Images\image1.jpg

I created a virtual directory on IIS resources.mysite: Inside my website I reference the sheet like this resources.mysite/myTheme.css

But inside myTheme.css I reference pictures from ../Images/images1.jpg.

So the problem is that image1.jpg is not found because it is relative to the physical folder and not the virtual folder on IIS.

Can I solve this problem without modifying the style sheet ?

share|improve this question

One trivial solution to that problem is to use URL Rewrite ( to expose the same /CSS/myTheme.css directly over /myTheme.css, that way when the browser resolves the relative URLs it will resolve them correctly. So that should work, I should also mention that IIS URL Rewrite is EXTREMELY performant and plays nice with kernel caching and more that would not affect any performance.

So in other words just install URL Rewrite and create a web.config file at the root of your site with the following and you should be good to go.

        <rule name="Expose Theme CSS" stopProcessing="true">
          <match url="^myTheme.css" />
          <action type="Rewrite" url="/CSS/myTheme.css" />
share|improve this answer

No. You can't use the ../ to get to a high level folder than the root folder (of the site or the virtual directory, whichever applies).

This would be a major security issue if you could. People could do things like and start downloading your registry, or the SAM database or who know what else they'd find interesting.

share|improve this answer
ahh remember when IIS 4(i think maybe 5 too) would let you do this :) – Zypher May 23 '10 at 16:34

Your Answer


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