开发者

301 redirect based on file extension to a new extension

My current URI is http://example.com/blog/clients/clientname/?file=media.flv.

I need all hits to that exact UR开发者_开发技巧I structure to 301 to the same structure but change the file extension to MP4.

What are the htaccess rules I need to setup?


Following code in .htaccess should work for you:

Options +FollowSymlinks -MultiViews
RewriteEngine on

RewriteCond %{QUERY_STRING} ^(file=.*)\.flv [NC]
RewriteRule . %{REQUEST_URI}?%1.MP4 [L,R=301]

Remember you cannot match QUERY_STRING in RewriteRule.

NC flag is for ignore case comparison, you can remove it if you don't need it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜