0

I want http://www.mywebsite.com/play.m3u8?id=1234 to redirect to http://www.mywebsite.com/play.php?id=1234(play.php will produce the actual m3u8 url) using .htaccess rewrites rules! (In another word I want to "package" it into a fake .m3u8 file so that xbmc/kodi would process it)

Could any one show me how i create such .htaccess file. Thanks in advance.

user1788736
  • 2,727
  • 20
  • 66
  • 110

1 Answers1

1

You can use that in your .htaccess:

RewriteEngine on
RewriteRule \.m3u8$ /play.php [NC,L]
Croises
  • 18,570
  • 4
  • 30
  • 47
  • thanks for reply . I tried it by typing the url on the browser like this http://www.mywebsite.com/test/play.m3u8?id=1234 and it didn't run the play.php script instead i got page not found( i placed .httaccess on root). could you tell me what might be wrong ? – user1788736 Nov 29 '15 at 00:37
  • `play.php` is also on root ? – Croises Nov 29 '15 at 01:42
  • I had to change to RewriteRule \.m3u8$ /test/play.php [NC,L] to make the redirect work!Redirect works but xbmc still can't play such urls! – user1788736 Nov 29 '15 at 23:54
  • Because you use query string ? You can use link like that `http://www.mywebsite.com/play_1234.m3u8` with `RewriteRule _(\d+).m3u8$ /test/play.php?id=$1 [NC,L]` – Croises Nov 29 '15 at 23:59
  • i use http://exampleMysite.com/test/play.m3u8?id=1234.it redirect to php script and php generates the actual m3u8 url but xbmc doesn't play it! what you mean by query string ? should i use above rewrite rule instead of the first one that you posted ? – user1788736 Nov 30 '15 at 00:53
  • Query string is the part after `?`. You can change and use id in the file name like in my last comment. – Croises Nov 30 '15 at 00:58
  • I tried your second rewriterule but now http://www.mywebsite.com/play_1234.m3u8 doesn't redirect to actual php script! I wish it did so i could test it on xbmc ! – user1788736 Nov 30 '15 at 01:28
  • Yes, it redirects to the same php script ! With: `RewriteRule _(\d+)\.m3u8$ /test/play.php?id=$1 [NC,L]` if `play.php` is still in `/test/` directory. – Croises Nov 30 '15 at 07:25