Mixerguy Posted August 17, 2004 Posted August 17, 2004 Pretty long story, but bear with me as I think most of this info is important... I was working on creating some custom error pages and, as I understand it, it would require adding some "ErrorDocument" lines to my .htaccess file. Nothing I haven't done before, so I figure no big deal. At first, I thought about using the .shtml utility in Cpanel, but I don't think its able to do quite what I want (email webmaster). Anyway, I upload my custom error pages. I access my root via FTP using the standard lame-o Windows Explorer and find that there apparently is no .htaccess file in my root. For some reason or another, it doesn't occur to me that I have subdomains active and so, therefore, there HAS to be one somewhere. So before thinking, I create and upload my own. In order to test that this succeeded, I try to open some nonexistant page so I can get my custom 404. No luck - the standard IE 404 comes up. I made sure it was over the 512 bytes minimum, where IE automatically bypasses custom 404's and then re-FTP'd via Explorer to reopen the file to make sure all is cool there. When I reopen, I find out there is no .htaccess file anymore. So, I figure something beyond my comprehension is going on and I install SmartFTP to see if it can shed some light on the subject. I connect and find that there is not only the one .htaccess file I uploaded, but 3 others as well - all with a .[10-digit number] extension. My questions are these: Why are there multiple .htaccess files here? What do they do? And, quite simply, how can I get my custom error documents to work? Many thanks in advance for your assistance! P.S. - Obviously, backups have already been made. Better safe, then sorry oh BTW Rock Sign Quote
TCH-Bruce Posted August 17, 2004 Posted August 17, 2004 (edited) You say you are using FTP with Internet Explorer? My guess is it's not displaying hidden files which is what the .htaccess file is. It is a hidden file. Go into file manager in cPanel and upload using that. The file manager displays hidden files. As for the error page not displaying. The only think I have done to create a custom error page was name it 404.shtml and stick it in the public_html folder. Didn't modify the .htaccess file at all. For subdomains, copy the custom 404.shtml into the proper folder. No need to edit the .htaccess. Almost forgot. The .htaccess files with the numbers in the filename are backups that cPanel makes when you edit your .htaccess file using cPanel. Or use something in cPanel that updates the .htaccess file. Edited August 17, 2004 by TCH-Bruce Quote
Mixerguy Posted August 17, 2004 Author Posted August 17, 2004 OK, as I've only done this once or twice before, perhaps I'm confused as to the process required to set this up. As shtml can't do what I'm looking to do, I did not use the shtml creation utility in Cpanel, but instead created my own custom error pages using PHP. My understanding is that in order to get these to work after uploading, I have to add the "ErrorDocument" lines to my .htaccess. Correct? In addition - ignoring the backups with the number extensions - I only have really one .htaccess file and it is the one I uploaded (possibly overwriting an original somewhere in the process). Also correct? Quote
TCH-Don Posted August 17, 2004 Posted August 17, 2004 Or if you add AddHandler application/x-httpd-php .htm .html .shtml to your .htacces file your 404.shtml file can have php in it. You can also add ErrorDocument 404 http://domain.com/error/404.shtml to keep your error page in a folder or direct errors to a 404.php file Quote
Mixerguy Posted August 19, 2004 Author Posted August 19, 2004 OK. Think I'm finally on the same mental page as everyone else. Thumbs Up I got to and edited the .htaccess file via the Cpanel File Manager, adding the following lines: >ErrorDocument 400 /errors/400.php ErrorDocument 401 /errors/401.php ErrorDocument 403 /errors/403.php ErrorDocument 404 /errors/404.php ErrorDocument 405 /errors/405.php ErrorDocument 500 /errors/500.php ErrorDocument 501 /errors/501.php ErrorDocument 503 /errors/503.php To be honest, those were the only lines in it. (Is that right?). Anyway, the document saves just fine. I tested the 401 (Unauthorized) error page by passwording a directory and then failing the login. The error page comes up just fine. Then, I tested the 404 (Page Not Found) by attempting to access a nonexistant page (something like "www.domain.net/dontexist.htm"). I still get the standard Internet Explorer 404 error page. Anyone have any ideas? Quote
DarqFlare Posted August 19, 2004 Posted August 19, 2004 (edited) The only thought I have is that it cannot find the /errors/404.php file. Try using the absolute path for the definition: >ErrorDocument 404 http://www.domain.ext/errors/404.php Edited August 19, 2004 by TCH-Robert Quote
Mixerguy Posted August 19, 2004 Author Posted August 19, 2004 Awesome! It works! Many thank you's, Robert. I've said it before and I'll say it again: Rock Sign Two last things now: Is it supposed to show the address of the error page in the address bar when pulling up the 404? I didn't think it was supposed to do that, but I forget. In addition, after adding the absolute address to all the other lines as well, my 401 no longer works properly? It just doesn't seem to be my couple of days. Here's the code as it sits now: >ErrorDocument 400 http://www.wendlandfamily.net/errors/400.php ErrorDocument 401 http://www.wendlandfamily.net/errors/401.php ErrorDocument 403 http://www.wendlandfamily.net/errors/403.php ErrorDocument 404 http://www.wendlandfamily.net/errors/404.php ErrorDocument 500 http://www.wendlandfamily.net/errors/500.php ErrorDocument 501 http://www.wendlandfamily.net/errors/501.php ErrorDocument 503 http://www.wendlandfamily.net/errors/503.php Quote
Mixerguy Posted August 19, 2004 Author Posted August 19, 2004 Is it ok to feel like a complete and utter moron? I figured out my [stupid] mistake. Internet Explorer overrides custom 404's less than 512 bytes, so I made sure my code was above that. However, nearly all of it is PHP; IE never sees the PHP section. Therefore, the chunk IE actually sees is less than 512. IE takes over and displays its 404. I really want to thank M$ for doing that... really... I think Bill needs a good . Anyway, the "ErrorDocument 404 /errors/404.php" line and its companions work just fine now. Thanks for putting up with me while I worked through my incompetence. Thumbs Up Quote
TCH-Don Posted August 19, 2004 Posted August 19, 2004 That a good point that many of us may not have thought of ether I guess I lucked out that mine is larger with out the php. Thanks for the heads up, this will help others. Thumbs Up Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.