Forum Moderators: phranque
This would mean that requests for ftp/, ftp/user1, ftp/everyone would all be redirected to my custom 403 page 403.php.
This is what I have so far:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ftp/(.*) blog/(*) [L]
</IfModule>
I don't want to actually redirect users, I just want to load 403.php instead of the requested file.
THe other thing i've noticed is that it only redirects when the file requested actually exists.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} !-d [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ftp/(.*) 403.php [L]
</IfModule>
This hasn't solved it either.
If the directory is forbidden, then they get no access, and that includes "no access to information about whether particular files exist in that directory."
I suppose you could use some of the "file-exists" constructs you posted above to *not* return a 403 if the file doesn't exist, and therefore, fall through to the default 404-handling, but really, why bother? To paraphrase Albert Einstein, "Keep your code as simple as possible, but no simpler."
I see many people make a big mistake when blocking access by malicious agents or troublesome people: They put up an "Access Denied" page that contains far too much information -- For example, they'll crow about "We blocked your site downloader."
Well, the *really* troublesome people will read that, and then proceed to do some searches until they find out how a Web site might identify a site downloader, stumble across the phrase "User-agent header" and then proceed to "Spoof user-agent header" or "Change user-agent header." They find that information, modify or configure their site downloader to spoof IE or Firefox, and then come back and raid the whole site.
So, the "bragging error page" has just defeated its own purpose.
Really, the less information you give out, the better -- I've got some error pages that, under specific circumstances, look like the malicious visitor just triggered a fatal scripting error... They get a 403 or 500 response code and a short string of apparently random characters. ;)
Jim