2014-10-28 137 views
1

我在数据库中有1000个静态html页面文件和html数据。 现在我想移动到亚马逊S3服务器,我将所有的静态文件移动到S3。 如何将路径路由到新位置,我无法更新所有页面和正确的图像路径。 喜欢:将静态文件路由到asp.net中的新路径mvc

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

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

我需要一个路线请求重定向到新的位置,而不是更新的所有文件。

回答

2

可使用URL重写在你的web.config这样的:

<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> 
+2

当然可以,并且关于{R:X} {R:X}被用作从规则模式反向引用()。你可以在这里找到更多关于:http://stackoverflow.com/questions/16998832/iis-url-rewrite-rn-clarification – 2014-10-28 12:02:48