Using .htaccess to send people to webpage when trying to access a specific video file

Discussion in 'Apache' started by hannesjohnson, Jul 22, 2008.

  1. #1
    Hi

    I have a video file on my server and when people try to access it I want to send them to a specific web page instead.

    I tried this in .htaccess but it didn't seem to work:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^videos/2008/my-video.avi$ videos/2008/video.html
    </IfModule>
    Code (markup):
    I also tried some different variations, like:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} ^/videos/2008/my-video.avi.*$ [NC]
    RewriteRule . /videos/2008/video.html [L]
    </IfModule>
    Code (markup):
    But that didn't work either...

    Do you have any idea what I might be doing wrong?

    - Hannes
     
    hannesjohnson, Jul 22, 2008 IP
  2. pr0t0n

    pr0t0n Well-Known Member

    Messages:
    243
    Likes Received:
    10
    Best Answers:
    10
    Trophy Points:
    128
    #2
    You do not need that "ifmodule" part video for .htaccess file. You should place this in your .htaccess:

    
    RewriteEngine On
    RewriteBase /
    RewriteRule ^videos/2008/my-video.avi$ /videos/2008/video.html [L]
    
    Code (markup):
    That should do the trick.
     
    pr0t0n, Jul 23, 2008 IP
  3. hannesjohnson

    hannesjohnson Guest

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    OK, thanks.

    Seems like I also had to move this to the top of the .htaccess file because there were a few other RewriteRules there apparently interfering with it when I had it at the bottom...
     
    hannesjohnson, Jul 24, 2008 IP