mehr
mehr

Reputation: 845

Route static files to new path in asp.net mvc

I have 1000 static html page files and html data in Database. Now i want to move to amazon s3 server, i will move all of my static files to s3. How i can route the path to the new location, i can't update all of the pages and correct images path. like:

<img src='/myfiles/images/blog/20140606/flow.jpg'/>    

to

Request: /myfiles/images/blog/20140606/flow.jpg
Redirect to: htps://xxx.s3.amazonaws.com/myfiles/images/blog/20140606/flow.jpg

i need a route to redirect the request to new location instead of update all files.

Upvotes: 2

Views: 1164

Answers (1)

Amr Elgarhy
Amr Elgarhy

Reputation: 68902

May be using a url rewrite in your web.config like this:

<rewrite>
    <rules>
      <rule name="Rewrite to s3" stopProcessing="true">
        <match url="^/myfiles/images/blog/(.*)" />
        <action type="Rewrite" url="s3/mybucketname/{R:1}" appendQueryString="false" redirectType="Found" />
      </rule>
    </rules>
  </rewrite>

Upvotes: 3

Related Questions