views:

426

answers:

1

I have a webapp that on my local machine runs as the root url, however on the server it runs in new virtual directory of another website.

The problem i have is that all the images have been written like so;

<img src="/Images/image.jpg" .../>

However when i upload the webapp to the server the image needs to be like this

<img src="/myApp/Images/image.jpg .../>

so i thought i would use the rewrite module to change the image path and save myself some time. Using IIS7 I have the following for the pattern;

*/Images/*

and this for the actions rewrite property

http://myDomain.com/myApp/Images/{R:2}

however i doesn't work - this image is still showing as not found - can someone point out my mistake.

Thanks in advance

A: 

The pattern ought to be a regular expression, try match as

  ^.*?/Images/(.*)

and the rewrite url as

 /myApp/Images/{R:1}

Note this needs to be in the web.config for the site not the application.

AnthonyWJones
Still not working, my config file looks like this<rules><rule name="Redirect Images" patternSyntax="ECMAScript" stopProcessing="false"> <match url="^.*?/Images/(.*)" /> <action type="Rewrite" url="/myApp/Images/{R:1}" /></rule></rules>
Gareth
You've added this to the sites web.config right? It won't work if you place in your application web.config.
AnthonyWJones
yes added to the web.config
Gareth
Yeah, the ambiguity remains, which web.config? There are more than one at work here, the site's or the application's?
AnthonyWJones