如何使用apache的RewriteEngine重写文件名以包含get数据?

时间:2013-06-28 07:48:08

标签: apache .htaccess url-rewriting

最差冠军的奖品归我所有:)

您好,

当我需要网址时,我有一个特殊的情况:

sample.mp4

在内部重写为:

sample.mp4?start=400&end=500

因此,对该文件的每个请求都只会让我预览视频。

这是否适用于apache RewriteEngine?

1 个答案:

答案 0 :(得分:0)

试试这段代码,这适用于sample.mp4?start = 400& end = 500以及start和end的任何通用值

RewriteCond %{REQUEST_URI}  ^/sample\.mp4$
RewriteCond %{QUERY_STRING} ^start=(.*)&end=(.*)$
RewriteRule ^(.*)$ http://example.com/sample.mp4? [R=301,L]