Is it possible to rewrite somehow www.mysite.com/Pictures to point to test.mysite.com/Pictures or even more broadly www.someothersite.com/Pictures ?

Note: www.mysite.com and test.mysite.com are on separate machines and built with different technologies (one is ASP.NET and the other is PHP) but I have access to both of them.

I want that when I reference a picture like www.mysite.com/Pictures/pic12345.png the picture to display correctly, even though there is not /Pictures folder on that server and the pictures has to be retrieved by going to test.mysite.com/Picture/pic12345.png

Ideally I want to do this in IIS6 to test it. However I am interested if it possible to do in any webserver (Apache, IIS7)

migrated from stackoverflow.com May 25 '10 at 13:55

This question came from our site for professional and enthusiast programmers.


Been a while since I worked with Asp.NET but you could write a http module that handles this for you.

  • Thank you, I didn't think about that, for some reason, will look into it. – Liviu May 25 '10 at 11:17

Use a .htaccess file (on www.mysite.com), within which you want:

Redirect 301 /Pictures www.someothersite.com/Pictures

Alternatively, you could use mod_rewrite:

RewriteEngine on
RewriteRule ^Pictures/(.*)$ www.someothersite.com/Pictures/$1
  • Wouldn't that work? if I have a picture like this <img src="mysite.com/Pictures/Pic12345.jpg" alt="some pick"/> will it display it correctly? – Liviu May 25 '10 at 11:16
  • I think you might need ModRewrite for that usage. Hold on – Eric May 25 '10 at 11:26
  • Did both work, or just the second one? – Eric May 25 '10 at 11:39
  • Couldn't make it to work with neither yet, but it seems the second one is the right way to go, I will give it a few more tries or try variations of this. – Liviu May 25 '10 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy