[PHP] 404 errors
I get a lot of 404 errors. Is there a way in PHP to redirect them in such a way as it does not burn my bandwidth? Or (an Apache trick I learned once) to discourage them by referring them to localhost? Or something? Something I can embed in PHP. John -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 404 errors
John Taylor-Johnston wrote: I get a lot of 404 errors. Is there a way in PHP to redirect them in such a way as it does not burn my bandwidth? Or (an Apache trick I learned once) to discourage them by referring them to localhost? Or something? Something I can embed in PHP. IMHO unless there's a very good reason for it PHP should never get involved in handling 404 errors. By the time it gets to PHP it's wasted a fair amount of capacity. On most of my sites, where I don't need to handle 404's intelligently (i.e. showing a search results page based on the entered URL) I use the following in the apache configuration... ErrorDocument 404 404 Not Found That simply makes PHP return 404 Not Found which is about the minimum amount of bandwidth you can get away with. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] 404 errors
On Tue, May 16, 2006 3:56 pm, John Taylor-Johnston wrote: I get a lot of 404 errors. Is there a way in PHP to redirect them in such a way as it does not burn my bandwidth? Or (an Apache trick I learned once) to discourage them by referring them to localhost? Or something? Something I can embed in PHP. header(Location: 127.0.0.1); would be the PHP equivalent of that Apache trick. Not sure how effective it is... Another option is to do this: ?php if (bad_user()){ sleep(mt_rand(1, 60)); } ? You have to figure out a way to code bad_user() to only catch the bad guys, but they'll decide your server is too slow to be useful, or that they've trashed it with their DOS attack, and move on to another victim. Honestly, though, PHP is almost-for-sure the wrong place to attack this problem... Not saying I know what is the RIGHT place, mind. :-) -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php