开发者

Apache .htaccess mod_rewrite RewriteCond Problem

开发者 https://www.devze.com 2023-02-16 03:52 出处:网络
I\'m attempting to get a RewriteCond/RewriteRule pair working, which results in a 404 error unless I uncomment the RewriteCond, in which case everything is redirected.

I'm attempting to get a RewriteCond/RewriteRule pair working, which results in a 404 error unless I uncomment the RewriteCond, in which case everything is redirected.

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /path/
RewriteCond /var/www/site/downloads/$1 -F
RewriteRule ^(.+)$ getdownload.php [L]
</IfModule>

The idea is, if the file exists in the downloads directory to send the user to the getdownload.php script, which distributes the download, assuming they have permission.

Any thoughts as to why 开发者_如何学编程this would be failing?


RewriteCond %{SCRIPT_FILENAME} -f
RewriteRule path/downloads/(.*) path/downloads/getdownload.php? [L]

Still shows downloads/index.php in URL, but serves /downloads/getdownload.php content, AND makes sure it's a file. (note: my .htaccess file is in the top level of my test site.)

If you want to put it into /downloads/ you can delete "path/downloads/" from both sides of the rule.

0

精彩评论

暂无评论...
验证码 换一张
取 消