Reputation: 1
I created a video page that will display a default video OR load in a video sent via a querystring. It can be accessed in any of these ways:
/video.php
/video.php?id=VIDEO_ID
/video.php?id=VIDEO_ID&time_offset=TIME_OFFSET
Using htaccess rewrite I'd like to have friendly urls that rewrite this as follows:
/video -> video.php
/video/VIDEO_ID -> /video.php?id=VIDEO_ID
/video/VIDEO_ID/TIME_OFFSET -> /video.php?id=VIDEO_ID&time_offset=TIME_OFFSET
For Example: /video/cBPg3iof4J4/ -> /video.php?id=cBPg3iof4J4
Since a user can go a) to the video page, b) to the video page with a video id, and c) with a video id AND time offset, how do I account for all these scenarios with .htaccess re-write? I've tried the code below:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^video/$(.*) video.php?id=$1 [L]
RewriteRule ^video video.php [L]
Upvotes: 0
Views: 758
Reputation: 1901
The ^
indicates the start of the url $
indicated the end of the url.
RewriteEngine on
RewriteRule ^video/?$ video.php [L]
RewriteRule ^video/(.*)/(.*)/?$ video.php?id=$1&time_offset=$2 [L]
RewriteRule ^video/(.*)/?$ video.php?id=$1 [L]
Upvotes: 1