Forum Moderators: phranque
Is it possible to use a rewrite so that any requests for the .wmv does not fire up their Media Player but sends them to a .html instead?
Something like this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^http://nn\.nn\.nn\.nnn\/movies\/funny1\.wmv
RewriteRule ^(.*)$ [mysite.com...] [R=permanent,L]
RewriteCond %{SCRIPT_FILENAME} ([^/]+)\.zip$
RewriteRule ^.*$ www.mysitenamehere.com/download.php?file=%1 [R,L]
I've modd'd that to work in that any request for a .wmv file goes to the funny_videos.html page.
However, on that page is the true link to the .wmv and the redirect just seems to be going around in an endless loop! The page is presented but then apache see's that the page contains the .wmv and redirects it back to the .html again.
I guess I need to put the full hotlink path in the first line but then it doesn't work.
The problem is that someone has posted a direct link to a .wmv file (with ip address as the host not the domain :-( ) but I'd rather they got to that link via the info page first.
I can successfully redirect all requests to .wmv to the landing page but then on that page the .wmv 'redirects itself to the info page' kind of thing.
I guess I could get around this by converting the .wmv to a .mpg so that there is no recursive loop but I'm sure this can be done via a rewrite.
If the request is movies/funny1.wmv
then serve them
movies/funny_videos.html
Jim, I don't think I understand this. Surely the problem is not that the media player is calling the page but that an external link.
Excuse my ignorance with this but surely isn't the sequence of events this:
site www.widgets.com has a page with a link to a wmv on mysite
nnn.nnn.nnn.nnn/movies/funny1.wmv
If a user clicks that link their browser first connects to mysite. The webserver identifies the file as .wmv and instructs the users PC to fire up media player.
Therefore, we should be able to use .htaccess to trap this?
I know that I can redirect any requests for all .wmv files. Why can't I redirect for just requests for funny1.wmv?
How about another solution! Redirect if any .wmv is called and the referrer is www.widgets.com? That will get around the looping problem.
1. Apache detects a request for .wmv AND that the refferer is www.widgets.com
2. Apache redirects the user to www.mysite.com/movies/funny_videos.html
3. Apache detects that this new page is requesting a .wmv however, the referrer is now mysite.com so no redirect takes place and the file plays
1. Detect calls for any .wmv file and redirect to landing page.
2. Have the .wmv file renamed to .wm1
RewriteEngine on
RewriteCond %{SCRIPT_FILENAME} ([^/]+)\.wmv$
RewriteRule ^.*$ [mysite.com...] [R=permanent,L]
In funny_video1.html there is a link to play funny1.wm1 so the redirect does not do it's thing on the second request.
Also, I have it set to autoplay onthe page:
<OBJECT ID="MediaPlayer" WIDTH="320" HEIGHT="240"
CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
TYPE="application/x-oleobject">
<BR>
<PARAM NAME="FileName" VALUE="funny1.wm1">
<BR>
<PARAM NAME="autostart" VALUE="1">
<BR>
<PARAM NAME="showcontrols" VALUE="0">
<BR>
br> SRC="1457.WMV"<BR>
WIDTH="320"<BR>
HEIGHT="240"<BR>
AUTOSTART="1"<BR>
SHOWCONTROLS="0"><BR>
<BR>
</OBJECT>
In the meantime, take a look at your Object code. I seem to recall that IE and Mozilla browsers use different methods, OBJECT and EMBED, and that there is a trick to make it work with both. I found a solution in the MS Media Player knowledge base several years ago, IIRC.
Are those <BR>s actually needed?
Jim