Rewriting URLs for Virtual Video Clips
Virtual Video Clips
We have a full length video available at the following URL 'http://www.example/com/video.mp4'. A preview can be provided by adding the 'start' and 'end' parameters, say for example we want to use 30 seconds of preview starting at the 15th second. We then have the following URL 'http://www.example.com/video.mp4?start=15&end=45'.
This will work fine when using wget / curl, unfortunately a lot of Flash players don't behave correctly as they don't allow video URLS with query parameters in them. They just blindly append '?start=xyz' to the URL making it invalid.
To work around this we can move the start and end parameters to the server side configuration. This has a couple of advantages:
- The user doesn't see the '?start=15&end=45' parameters any more.
- Flash players assuming that they are adding the first query parameters work again.
In your .htaccess:
RewriteEngine On # From: http://www.example.com/video.mp4/preview?start=xyz&foo=bar # To: http://www.example.com/video.mp4?start=xyz&foo=bar&vbegin=15&vend=45 RewriteRule ^(.*)/preview\?(start=.*)$ $1?$2&vbegin=15&vend=45 [L]