Forwarding requests for relocated static content

I have a bunch of static content on a site that has always lived in the root directory like http://mysite.com/smiley.gif. I want to move it all to a subdirectory http://mysite.com/images/smiley.gif.

The problem is that years of content points to the first URL. What's the best way to forward those requests to the new locations?

Answers


We've recently done exactly this. We ended up using rewrite rules though IIS because they are applied very early in the pipeline and so was the smallest performance impact. Take a look at the UrlRewrite module for more info.

Just got our rules open, after installing the rewrite module in IIS, you add the following to your root Web.config. This rule would rewrite all *.gif requests, you might have to tailor it a bit.

<system.webserver>
    <rewrite>
        <rules>
            <clear />
            <rule name="gif" stopProcessing="true">
                <match url="^(.*).gif" />
                <action type="Rewrite" url="/images/{R:0}" />
            </rule>
        </rules>
    </rewrite>
</system.webserver>

Need Your Help

Access to an object created in page from a class

c# asp.net

I have a page, Default.aspx, with its own code-behind file like this:

Gmaps.js stopped working

javascript jquery google-maps gmaps.js

from one day to another the Gmaps.js Library stopped working... I've created a map with 3 Markers on it and they had InfoWindows and I've added a little routing option in the InfoWindow where you

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.