0

I am hosting videos mostly for non-smart phones, but for smart phones I want to give better quality videos. The way I am doing it right now is detecting user agent with htaccess file since most of the non-smart phones ignored javascript and php. My problem is that I have one htaccess file for each video since I don't know what video people are trying to watch. Is there a better way to do this? Thanks!

herrdragon
  • 13
  • 3

1 Answers1

1

Make a sensible, generalised file/folder structure that allows you to apply generalised rewrite rules. E.g.:

videos/
    low/
        abc.mp4
        def.mp4
        ...
    high/
        abc.mp4
        def.mp4
        ...

With URLs like:

example.com/videos/abc.mp4

With rewrite rules like:

RewriteCond <is mobile user>
RewriteRule videos/(.*) videos/high/$1 [L]

RewriteRule videos/(.*) videos/low/$1
deceze
  • 510,633
  • 85
  • 743
  • 889
  • Thank you for your response. This is what I was looking for. I don't understand the code very well but I'll give it a try right now! Thanks. – herrdragon Apr 21 '14 at 14:01
  • deceze, I have the htaccess in the videos folder and the link I am writing like: www.mysite.com/videos/video1.mp4 but it says file not found – herrdragon Apr 21 '14 at 14:42
  • Ok, I've trying different combination of this and for some reason it is not redirecting if I don't put the file name on the htaccess file. Nice explanation by the way. – herrdragon Apr 21 '14 at 18:46
  • I got it to work. I just had to put RewriteRule ^(.*)$ http://mywebsite.com/videos/high/$1, so I'll take it as a correct answer. – herrdragon Apr 22 '14 at 19:47