Reputation: 3773
I am attempting to use my .htaccess
and mod_rewrite to redirect requests for mp3 files inside a directory called download
to a PHP file called download.php
. This file makes a Google Analytics request and then does a server side redirect to the actual mp3 file located in the files
directory.
The rewrite should specify the mp3 name as a url parameter which I can access from the PHP via $_GET. However this isn't working.
My .htaccess looks like this
RewriteEngine On
RewriteRule ^.*download/(.*)\.mp3$ /download.php?url=http://static.example.com/files/$1.mp3 [QSA]
The download.php
file is executed but if I do var_dump($_GET);
it returns with array(0) { }
What am I doing wrong?
Upvotes: 2
Views: 75
Reputation: 785128
Most likely you have MultiViews
enabled, disable it by using this line on top of .htaccess:
Options -MultiViews
MultiViews
is used by Apache's content negotiation module
that runs before mod_rewrite
and and makes Apache server match extensions of files. So /file
can be in URL but it will serve /file.php
.Upvotes: 2