Key_Master

msg:4434151 | 10:16 pm on Mar 27, 2012 (gmt 0) |
You can do this easily with mod_rewrite but using SetEnvIf gets a little more complicated (or not depending on your view). When you set an environmental variable in .htaccess, your custom-block.php script has access to that same variable and its value. So in your script, you would need some code that would work check for that variable:
if variable bad_bot=1 { do something; }
|
lucy24

msg:4434186 | 11:17 pm on Mar 27, 2012 (gmt 0) |
You can definitely do it with a redirect, although that might be considered cheating. That is: redirect your Bad Files to a special directory, and set a different 403 document for that one directory. That's assuming they follow the redirect, which they might choose not to do. But if they're unwanted robots, you probably don't care if they just leave quietly. ____ Here's another thing that will not work (I tried) ;) If you set more than one ErrorDocument, like ErrorDocument 403 blahblah ErrorDocument 403 blahblah the most recent one will quietly replace any earlier ones. But if you block your Bad Requests from the most recent ErrorDocument, they will not bounce back to the earlier ErrorDocument. Instead you'll get an error message from the server.
|
Seedy

msg:4434284 | 7:34 am on Mar 28, 2012 (gmt 0) |
Plenty of food for thought. Many thanks for your replies guys ('n' gal).
|
Seedy

msg:4434977 | 8:24 pm on Mar 29, 2012 (gmt 0) |
Guys - Lucy specifically - if I understood you correctly, what's the actual method of specifying a different error page to your regular 403 in htaccess for your SetEnv rules please? I'm wanting to give the redirect method a try first but am unsure how to action it in htaccess. Thanks in advance
|
lucy24

msg:4435023 | 10:43 pm on Mar 29, 2012 (gmt 0) |
With the redirect method you don't use SetEnv at all. (I looked pretty hard, as I assume you did, but couldn't find an env= envelope. Just Files and Directory, and I forget the third.) You put an htaccess in the Directory For Icky Robots, with its own ErrorDocument blahblah statement. For example: my top-level htaccess has a series of ErrorDocument 404 /boilerplate/missing.html for the assorted common errors. Then, in the /dp/ directory I've got a one-line htaccess that says ErrorDocument 404 /dp/missing.html If someone's in this directory at all, they are probably following some ancient Forums link that I've forgotten all about, so they get customized information. A directory-specific ErrorDocument statement overrides your generic rules in exactly the same way that you can switch auto-indexing off or on for individual directories. It will be inherited by subdirectories-- if there are any-- but will have no effect on other directories.
|
Seedy

msg:4435189 | 11:18 am on Mar 30, 2012 (gmt 0) |
Understood. I'll give this a go and see if it's better than other methods. Thank you Lucy.
|
|