View Full Version : More .htaccess Questions
01-05-2000, 03:28 PM
Hello Fellow Tylenol Users <g>.
I have a modified .htaccess file in my root that works perfectly to help point the error to an .shtml page versus the standard .html pages.
How can I get that same thing to work in the sub-directories? Another .htaccess in each one of them pointing back to the error page in the root or modify just the one to intercept all of the errors and point them to the same page?
Take care & best of luck to all during this new year!
Baseball History At Its Best!
01-05-2000, 03:35 PM
I use Cliff's 404 script:
Any 404 error throughout your site will be redirected to a page of your choice, regardless of the extension.[nbsp][nbsp]It also logs where the errors are coming from, which is kind of nice.
01-05-2000, 03:45 PM
No need for a script. Just specify the full (virtual) path to your 404.shtml page:
ErrorDocument 404 /404.shtml
Assuming 404.shtml is in your doc root. The .htaccess file will span through all subdirectories unless if finds another ErrorDocument 404 specific to a subdirectory...
01-05-2000, 03:52 PM
Yeah, but does that method log who's referring the 404's?[nbsp][nbsp];)
01-05-2000, 04:05 PM
No, that's what your stats and referer logs are for ;)[nbsp][nbsp] Plus I prefer not to use a CGI to handle errors for various reasons **especially** for 500 errors... for example, if anything goes wrong and the script handling 500 errors fails, you get a loop situation... Error --> Pull Error Page (CGI) --> CGI errors --> Pull Error Page (CGI) --> CGI errors....... ;)
01-05-2000, 04:32 PM
Ok, good comebacks...[nbsp][nbsp]I find the output from the 404 script much easier to read than stats and referrer logs, but that's just me.[nbsp][nbsp]I'm sure you're used to straining your eyes over that sort of stuff.[nbsp][nbsp]:)[nbsp][nbsp]I can see the potential for the endless loop situation.[nbsp][nbsp]Do scripts suddenly just break after working flawlessly for long periods...?[nbsp][nbsp]How's that for an impossible question to answer?![nbsp][nbsp];)[nbsp][nbsp] Around and around we go...
01-05-2000, 06:49 PM
Yes it can happen, I would suggest you do what Justin Recommend. If you would like to have a referral on the error page I would Recommend you put in something like a counter that shows referrers on the error page like http://usa.nedstat.net/
That would be the easiest solution I can think of :)
[This message has been edited by elite (edited 01-05-00@6:52 pm)]
01-06-2000, 01:53 AM
There is nothing at all wrong with using a script to handle HTTP errors, though I personally would not do this for 500 errors. Scripts don't break *on their own*, but things do happen... suppose TeRRa happens to be bringing a new copy of Perl online... just about any situation can arise... think of all of the things that ccould happen on a server shared by many other users...
As for logging referers, you could use PHP for this, quite easily - though I personally just keep an eye on the logs (if I see a lot of 404's for a particular file in my stats, I look for the referer, and if there are many different referers, usually I just upload a copy of the file to where they think it should be ;) )
01-09-2000, 12:56 AM
Ok, I decided to heed Justin's advice.
ErrorDocument 404 /404.shtml However, this only seems to work for files/directories under "www" -- is there any way to also make it work for mis-typed names in the cgi-bin?[nbsp][nbsp]Would each cgi directory need its own .htaccess?
01-09-2000, 01:41 AM
.htaccess files cascade - eg, if you place one in /www and there is not one in /www/foo, it will always search up one until it finds one (technically it's backwards but you get the poing ;) )
Your /cgi-bin is not part of your /www directory - so placing the .htaccess file in /big/dom/xyourdomain/ (eg, up one level) will cause it to work for the /cgi-bin as well :)
Hope this helps.
01-09-2000, 02:43 AM
Thanks Justin, that solved it.[nbsp][nbsp]I was beating up the wrong tree...[nbsp][nbsp]Does this make any sense to you:
I had a 404.html file as part of the 404.cgi script I was using.[nbsp][nbsp]It was in the /www/ directory, although it wasn't being used.[nbsp][nbsp]Instead, 404.cgi was directing to menu.shtml.[nbsp][nbsp]When I deleted 404.cgi and changed the .htaccess, any 404's in the cgi-bin were directing to the old 404.html page (as opposed to 404.shtml as specified in .htaccess).[nbsp][nbsp]When I deleted 404.html, it went to a generic 404 page.[nbsp][nbsp]Is there some characteristic of the cgi-bin that looks for 404.html by default?
01-09-2000, 04:55 PM
I have to side on a 404 script personally.[nbsp][nbsp]And while I understand the 500 loop error, should it ever occur, I enjoy the date stamped logging feature of the script I use.[nbsp][nbsp]Not that the error logs FQ provides aren't useful, but they don't tell you when the error occurred, something which when a site is frequently updated, are very useful pieces of information.
And since the script I use only refers 404 errors, I think it works pretty well.
Anyway, isn't there a manner in which to specify various types of errors and refering pages in the .htaccess file?[nbsp][nbsp]So theoretically, one could use a 404 script for 404 errors, and standard template pages for 500s, 403s, etc.?
The Internet's Premier site for everything Charisma.
01-22-2000, 11:57 AM
I'm confused as heck on this one:
%% [Wed Jan 19 06:29:19 2000] GET /cgi-bin/404.cgi HTTP/1.0
%% 404 /big/dom/xrun_down/cgi-bin/404.cgi
script not found or unable to stat
I'm seeing this a lot in my error logs since removing 404.cgi as discussed above.[nbsp][nbsp]I have two .htaccess files, one in the /www/ directory and one in /big/dom/xrun_down/ (I suppose just the latter would work, but they are identical), and neither has any reference to 404.cgi.[nbsp][nbsp]So, any ideas what's calling it???[nbsp][nbsp]I cannot duplicate the error...
vBulletin® v3.6.8, Copyright ©2000-2013, Jelsoft Enterprises Ltd.