English 中文(简体)
Tricking IIS 6.0 html web site into thinking it s at the root
原标题:
  • 时间:2009-11-11 22:10:59
  •  标签:
  • html
  • iis-6

I have no idea how to search for this one and perhaps Serverfault would be better but I ll start here.

I have a HTML web site running at the root of one of my webservers. It runs fine and dandy. I needed to make a test environment for it and where I can t run it in the root of the websever. I have to make a directory on the test server. For instance:

http://myTestserver/HtmlWebsite/index.html instead http://myProdserver/index.html

Once I throw it into the directory, most everything breaks. Some images won t load, javascript files can t be found, mass hysteria!

I discovered that the author of said site had used a mix of absolute and relative directory paths in all the files hence why some images loaded correctly.

I can go in and edit all the files to be relative. But I m wondering if I can make IIS 6.0 think that the web app directory it is in is the root of the webserver. So if I have an absolute path in the HTML like:

<img src="/_support/loadme.jpg" />

it would give me the image for either http://myTestserver/HtmlWebsite/_support/loadme.jpg or http://myProdserver/_support/loadme.jpg.

Can I get IIS 6.0 to do my bidding or am I stuck editing paths?

最佳回答

Unfortunately you ll either have to fix the absolute URL s across the site or run the site in it s own website in the root.

Is there no way you can get a new site created on the IIS6 test server?

问题回答

You should be able to by using URL rewriting

First you install ISAPI Rewrite, found here: http://www.helicontech.com/isapi_rewrite/

Then you create a config with the following rule:

RewriteEngine on    
RewriteRule (.+) /HtmlWebsite$1

What it does is it takes your request, say /index.html, and internally rewrites it to /HtmlWebsite/index.html, which is (ironically) tricking you into thinking you re calling from root when in fact it fetches it from the subfolder.

You might have to add or change the rule if you got more stuff on your test server, but that s the gist of it.





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签