Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2005
    Location
    UK, London
    Posts
    764

    .htaccess file to protect my video files

    I want to stop anyone from accessing my video files directly. I want to force them to view the video files from my playlist (.wvx for .wmv video files).

    Is there any way i can get a .htaccess file to only allow .wvx playlist file to load a video file and give a fake 404 error message to anyone who tries to access the real video file directly?
    Last edited by latheesan; 08-31-2005 at 03:00 PM.

  2. #2
    Join Date
    Dec 2003
    Location
    Vancouver BC, eh?
    Posts
    571
    Yes this can be done with mod_rewrite, if you have it installed on your apache server...

    If I didn't bung this up, it'd be something like this:

    RewriteEngine on
    RewriteRule ^([A-Za-z]+)\.wmv?$ playlist.wvx [L]

    You might have to change the directory structure, but right now I have it so if someone did this:

    somefile.wmv it would go to playlist.wvx instead. I don't think this would affect anything if the file is called internally in a page or script, but rather just if the person types the file directly in the url... but not 100% on this.

    maybe someone else can elaborate on it a bit.

  3. #3
    Join Date
    Jan 2005
    Location
    UK, London
    Posts
    764
    im not a big fan of mod re-write cause 1. i dun understand it very well 2. it's a bit complicated.

    picture this:

    folder name:
    summer

    files inside it:
    index.wvx
    beach_party.wmv
    .htaccess

    what i want to do on my index.html page is, link to the .wvx file like this:

    watch our summer party now. Click <a href=www.mysite.com/files/summer/index.wvx">here!</a>

    some one clicks that link and the play list will open the windows media player and show the beach_party.wmv video file

    no problem so far.

    Problem begins, when people click "View -> Source" and find the link to the .wvx playlist file and download it and then open it in notepad to find the real path to the .wmv video files.

    Right now, what i want to do is use the .htaccess file to deny access to any files in the folder with the extention .wmv and give the 404 error msg as if the file does not exist on the server.

    At the same time, the index.wvx file should be the only file that is allowed to acess any files in the folder with .wmv extension.

    how can i do this?
    Last edited by latheesan; 08-31-2005 at 04:54 PM.

  4. #4
    Join Date
    Dec 2003
    Location
    Vancouver BC, eh?
    Posts
    571
    Unfortunately that is where mod_rewrite comes in.. from what I can tell. You can tell it to throw a 404 error using a code at the end of the rewrite string, I forget the code, something like [P] ...

    mod_rewrite is really quite simple. Once you actually do something with it, it'll make sense, plus you learn something about regular expressions that crosses over into most programming languages...

  5. #5
    Join Date
    Jan 2005
    Location
    UK, London
    Posts
    764
    I've seen some tutorial abt where inside the .htaccess files, you can have settings like

    allow all or deny but allow from and so on

    so, for the functionality i wanted, i was thinking of the functions of the .htaccess

    so, should i give up the hope to do my feature request with .htaccess and start learning what is mod_rewrite?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •