Ron
Ron

Reputation: 4095

.htacces rewriterule to redirect if .exe/.zip

I am trying to write RewriteRule to redirect www.myweb.com/download/blabla.zip to > www.myweb.com/download/download.php?filedownload=blabla.zip

this is my .htaccess

Options +FollowSymlinks
RewriteBase /download/
RewriteEngine on 
RewriteRule ^(.*)$ download.php?filedownload=$1 [L]

the .htaccess located in the folder /download and the download.php file located also in the folder /download

but it doesnt work, no idea why... Can you help me?

BTW: the mod_rewrite is enabled.

Thanks.

Upvotes: 1

Views: 1470

Answers (1)

lll
lll

Reputation: 12889

Your RewriteRule is recursing on itself, and passing download.php as the parameter to itself.

You can try either of the following.

To match only zip/exe:

RewriteRule ^(.*\.(zip|exe))$ download.php?filedownload=$1 [L]

To exclude download.php from matches, place this before your RewriteRule:

RewriteCond %{REQUEST_FILENAME} !download.php

Upvotes: 3

Related Questions