Dream811
Dream811

Reputation: 61

How to use htaccess file for subdirectory url

My problem is to redirect from subdirectory link to one file. my current url

www.sample.com/stream/34/video.m3u8
www.sample.com/stream/35/video.m3u8

hope

www.sample.com/stream.php?param1=35&param2=video.m3u8

or

www.sample.com/stream/index.php?param1=35&param2=video.m3u8

Please save my life

Upvotes: 0

Views: 35

Answers (1)

MrWhite
MrWhite

Reputation: 45829

You can do something like the following using mod_rewrite in the root .htaccess file in order to rewrite the request to /stream.php?param1=<id>&param2=<file>:

Options -MultiViews

RewriteEngine On

RewriteRule ^stream/(\d+)/([\w-]+\.\w{2,4})$ stream.php?param1=$1&param2=$2 [L]

This assumes that the <id> (2nd path segment) is entirely numeric and the 3rd path segment consists of <filename>.<ext>. You should restrict this to m3u8 if that is all you are expecting.

Upvotes: 1

Related Questions