Help - Creating Custom Error Pages

Connect with other users about what to run on your webhosting (and how to run it) here.
Post Reply
winds
A semi-regular
A semi-regular
Posts: 19
https://www.youtube.com/channel/UC40BgXanDqOYoVCYFDSTfHA
Joined: Sat Jan 08, 2011 8:23 pm

Help - Creating Custom Error Pages

Post by winds »

Hey guys,
I've been trying to create custom error pages (404) without luck.
I uploaded a .htaccess file to my forums root directory, containing the following code:

Code: Select all

ErrorDocument 400 /error/404.php
ErrorDocument 401 /error/404.php
ErrorDocument 402 /error/404.php
ErrorDocument 403 /error/404.php
ErrorDocument 404 /error/404.php
ErrorDocument 500 /error/404.php
Then uploaded a sample 404.php file to my forum/error/ folder.
However when I do this, suddenly my forum (and all pages on the website) return an Internal Service Error which isn't my custom error page, nor should my board suddenly return that error.
Any suggestions?

Cheers!
.=QUACK=.Major.Pain
This is my homepage
This is my homepage
Posts: 1573
Joined: Sun Jun 26, 2011 8:03 am

Re: Help - Creating Custom Error Pages

Post by .=QUACK=.Major.Pain »

Think it should be in html.
ErrorDocument 403 /403.html
Visit gspreviews.com And Rate & Review Your Old & Current GSP's
Find Your GSP Coupons at gspreviews.com/coupons/
winds
A semi-regular
A semi-regular
Posts: 19
Joined: Sat Jan 08, 2011 8:23 pm

Re: Help - Creating Custom Error Pages

Post by winds »

I actually tried that as well (html) with same results. :(
User avatar
Edge100x
Founder
Founder
Posts: 13120
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Help - Creating Custom Error Pages

Post by Edge100x »

Are you certain that the files you are specifying exist in the correct places? Before you specify the ErrorDocument, try accessing them directly, using the same URL that it would -- for instance, based on what you put above, the file would need to be at:

http://yoursite.com/error/404.php

If you put the file into a "forum" subfolder, making the actual URL http://yoursite.com/forum/error/404.php, then you would need the .htaccess to reflect that, like:

ErrorDocument 404 /forum/error/404.php

I tested with a simple .html file on one of our test-hosting sites and it worked correctly for me.
winds
A semi-regular
A semi-regular
Posts: 19
Joined: Sat Jan 08, 2011 8:23 pm

Re: Help - Creating Custom Error Pages

Post by winds »

I just tried linking to the file in my browser and the file is indeed there.
I also tried editing the .htaccess file with http://www.mysite.com/error/404.php where mysite is my actual url. However the same problem still persists. My board suddenly becomes inaccessible, being replaced by an Internal Service Error and not my custom 404.php.

Edit: sorry forgot to add that my domain links to the forum folder, so that would be my root folder, no?
User avatar
Edge100x
Founder
Founder
Posts: 13120
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Help - Creating Custom Error Pages

Post by Edge100x »

Is the .htaccess file in the correct format -- straight text, as output by Notepad?

Do you have any other .htaccess that is overriding it and restoring default settings?

Are you using IE to access your site? If so, the Apache docs describe one possible limitation with that: http://httpd.apache.org/docs/2.0/mod/co ... ordocument

ErrorDocument definitely works out of the box.
winds
A semi-regular
A semi-regular
Posts: 19
Joined: Sat Jan 08, 2011 8:23 pm

Re: Help - Creating Custom Error Pages

Post by winds »

Yeah I am using a mac so with my text editor it saved as htaccess.rtf
I uploaded it using FileZilla FTP and renamed it to .htaccess
winds
A semi-regular
A semi-regular
Posts: 19
Joined: Sat Jan 08, 2011 8:23 pm

Re: Help - Creating Custom Error Pages

Post by winds »

I am using mybb forum software and that comes with an htaccess.txt file. However when opening that it says to use it, you need to rename it to .htaccess, so im assuming that file isnt being used?

There is another .htaccess file in my forum/inc/ directory protecting a config file.
User avatar
Edge100x
Founder
Founder
Posts: 13120
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Help - Creating Custom Error Pages

Post by Edge100x »

If you saved it in rtf format, that explains why it doesn't work. You need to save it as plain text, which will normally have a .txt extension.
winds
A semi-regular
A semi-regular
Posts: 19
Joined: Sat Jan 08, 2011 8:23 pm

Re: Help - Creating Custom Error Pages

Post by winds »

Hm sorry, im not typically a mac user, only using it since my PC is currently packed away for a move.
The text editor im using only allows me to save in: RTF, HTML, Word Format, and Word XML Format.
Are any of those the correct file type?

Edit: Sorry, there was a setting within the text editor to save in Plain Text. I'll try that now :D
Last edited by winds on Fri Apr 20, 2012 2:10 pm, edited 1 time in total.
User avatar
Edge100x
Founder
Founder
Posts: 13120
Joined: Thu Apr 18, 2002 11:04 pm
Location: Seattle
Contact:

Re: Help - Creating Custom Error Pages

Post by Edge100x »

None of those would work correctly, so you would need to use a different text editor that allows you to save as plain text.
winds
A semi-regular
A semi-regular
Posts: 19
Joined: Sat Jan 08, 2011 8:23 pm

Re: Help - Creating Custom Error Pages

Post by winds »

Ahhh thanks so much John, that was indeed my problem. Works like a charm now :D
Cheers!
BrendanG
Staff
Staff
Posts: 550
Joined: Mon Nov 06, 2006 2:55 pm

Re: Help - Creating Custom Error Pages

Post by BrendanG »

Rock on, I am very glad you got that figured out. I knew the .htaccess was right but the rtf issues I never even thought of. Thanks Edge for your help and Winds for following my instructions and posting here :D
winds
A semi-regular
A semi-regular
Posts: 19
Joined: Sat Jan 08, 2011 8:23 pm

Re: Help - Creating Custom Error Pages

Post by winds »

Yeah I definitely would have never figured that out haha. Thanks Brendan for recommending I post here. Very useful!
Post Reply