开发者

301 redirect based on file extension to a new extension

开发者 https://www.devze.com 2023-03-05 16:09 出处:网络
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

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

精彩评论

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