Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 9 of 9
  1. #1
    Senior Member BallardStudio's Avatar
    Join Date
    Jul 2011
    Posts
    143
    Member #
    28552
    Liked
    6 times
    Is the process of creating and posting a 404 error page difficult? I need to create one for my site, but haven't created one in the past.
    I'm an art director crossing paths between print and web design.
    http://www.ballardstudio.com

  2.  

  3. #2
    WDF Staff AlphaMare's Avatar
    Join Date
    Oct 2009
    Location
    Montreal, Canada
    Posts
    4,570
    Member #
    20277
    Liked
    878 times
    It's remarkably easy - just code up the page to look like you want it to and give it the name of the 404 page on your root. (mine is 404.shtml, but I have seen them as 404.html as well).

    When you upload it, make sure it is in the root of your site, and there you are!
    Good design should never say "Look at me!"
    It should say "Look at this." ~ David Craib


    http://digitalinsite.ca ~ my current site . . info@digitalinsite.ca ~ my email

    If you feel that someone's post helped you fix your problem, answered your question, or just made you feel better, feel free to "Like" their post. The "Like" link is at the bottom right of each post, along side the "reply" link. And if you are being helped here, try to help someone else - pass it on!

  4. #3
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,485
    Member #
    425
    Liked
    2783 times
    Depends on your server. You don't necessarily have to go the route of putting the 404 page in the root of your site on an IIS server, but you should add it in using the Error Pages section of the site within IIS.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)

  5. #4
    Banned
    Join Date
    May 2011
    Location
    Fairfax, CA
    Posts
    2,036
    Member #
    28003
    Liked
    126 times
    You can create a custom 404 page of a different name or in a different place if you add this to the .htaccess file (linux hosting only)

    ErrorDocument 404 "///http-error.cgi"

    then put this cgi file:

    Code:
    #!/usr/bin/perl -w
    use strict;
    my ($email_400, $email_500, $unfriendly_error, $redirect_to);
    my $main_domain=getpwuid($<);
    my @sendmail_path=(qw(/usr/sbin/sendmail -i -odb), "-fwebmaster\@$main_domain");
    
    ## Uncomment the below two lines to get emailed regarding the respective
    ## errors.
    
    #$email_400="webmaster\@$main_domain";
    #$email_500="webmaster\@$main_domain";
    
    ## If you want people to end up at a particular page for a 404 (Not Found) and
    ## you've used the $email_400 value above, then uncomment (and edit) the value
    ## below.
    #
    #$redirect_to = "/";
    
    ## Comment-out the line below to make the script return the actual HTTP status
    ## code, rather than 200 (success). Set the value to 1 if you want all users
    ## of MSIE (specifically those with "Show Friendly Error Messages" turned on)
    ## to be able to see your error pages.
    ## Set the value to 2 if you only want a 200 (success) if the file size is
    ## less than 512 bytes (currently the default).
    #
    $unfriendly_error=2;
    
    #
    ##
    ## End of configuration
    ##
    ## You shouldn't need to edit anything below.
    
    sub send_mail($$) {
            my ($to,$message)=@_;
            open(SENDMAIL, "|-", @sendmail_path, $to) or die $!;
            print SENDMAIL $message;
            close SENDMAIL;
    }
    
    use CGI;
    my $cgi=new CGI;
    
    if($ENV{REDIRECT_STATUS} == 404) {
        if($redirect_to) {
            # If there's a URL to redirect to, then let's do that.
            # The webmaster could in fact have set this directly in
            # the .htaccess file.
            print $cgi->redirect($redirect_to);
        } elsif(open IFILE, "<", "404.html") {
            # Otherwise, we send the default file
            my $status = 200;
    
            if($unfriendly_error == 1) {
                $status = 404;
            } elsif($unfriendly_error == 2) {
                if((stat(IFILE))[7] < 512) {
                    $status = 200;
                } else {
                    $status = 404;
                }
            }
    
            print $cgi->header(-type=>"text/html", -status=>$status);
            print while <IFILE>;
            close IFILE;
        } else {
            # If we can't find the 404 template, then we really should
            # just give an empty 404 (and hope the server fills it in)
            print $cgi->header(-status=>404);
        }
        if($email_400) {
            send_mail($email_400, <<EOF );
    To: $email_400
    From: webmaster\@$main_domain
    Subject: Missing file
    
    A request was received for the file $ENV{REDIRECT_URL}, which does not exist.
    
    The referrer was $ENV{HTTP_REFERER}.
    
    EOF
        }
    } elsif($ENV{REDIRECT_STATUS} == 500) {
        if(open IFILE, "<", "500.html") {
            print $cgi->header(-type=>"text/html", -status=>$unfriendly_error?200:500);
            print while <IFILE>;
            close IFILE;
        } else {
            # No template? Then just send a 500 and cross fingers.
            # Under no circumstances should this redirect.
            print $cgi->header(-status=>500);
        }
        if($email_500) {
            send_mail($email_500, <<EOF );
    To: $email_500
    From: webmaster\@$main_domain
    Subject: Script error
    
    A request was received for the file $ENV{REDIRECT_URL}, which caused an
    internal server error.
    
    The referrer was $ENV{HTTP_REFERER}.
    
    EOF
        }
    } else {
        # Last ditch effort: redirect to the home page.
        print $cgi->redirect("/");
    }

  6. #5
    WDF Staff AlphaMare's Avatar
    Join Date
    Oct 2009
    Location
    Montreal, Canada
    Posts
    4,570
    Member #
    20277
    Liked
    878 times
    [COLOR=rgb(0, 0, 0)]Yep - you're both right - I just outlined what I felt was the easiest way for the OP. [/COLOR]

    [COLOR=rgb(0, 0, 0)]I do make the error of assuming most people host on linux servers - my bad - I have no experience with IIS servers.[/COLOR]

    [COLOR=rgb(0, 0, 0)]And I would not mess with cgi for this - it's usually enough to put a smple line in yout .htaccess file:[/COLOR]
    [COLOR=rgb(0, 0, 0)]ErrorDocument 404 /your404.html (if it's in the root) [/COLOR]
    [COLOR=rgb(0, 0, 0)]ErrorDocument 404 /path/to/your404.html (if you want to put it somewhere else.)[/COLOR]
    Good design should never say "Look at me!"
    It should say "Look at this." ~ David Craib


    http://digitalinsite.ca ~ my current site . . info@digitalinsite.ca ~ my email

    If you feel that someone's post helped you fix your problem, answered your question, or just made you feel better, feel free to "Like" their post. The "Like" link is at the bottom right of each post, along side the "reply" link. And if you are being helped here, try to help someone else - pass it on!

  7. #6
    Senior Member BallardStudio's Avatar
    Join Date
    Jul 2011
    Posts
    143
    Member #
    28552
    Liked
    6 times
    My sever setup looks like this:

    http://i43.photobucket.com/albums/e3...b/Picture2.png



    <a href="http://s43.photobucket.com/albums/e3...t=Picture2.png" target="_blank"><img src="http://i43.photobucket.com/albums/e3...b/Picture2.png" border="0" alt="Photobucket"></a>
    I'm an art director crossing paths between print and web design.
    http://www.ballardstudio.com

  8. #7
    WDF Staff AlphaMare's Avatar
    Join Date
    Oct 2009
    Location
    Montreal, Canada
    Posts
    4,570
    Member #
    20277
    Liked
    878 times
    Oh. Well, that changes things.
    That is a picture on Photobucket, but I don't know what it is a picture of - is it your editing software?

    What text editor do you use for your code?
    When you are uploading files to your server how do you do it?
    Do you use an FTP program or go through a Control Panel of some sort?
    Good design should never say "Look at me!"
    It should say "Look at this." ~ David Craib


    http://digitalinsite.ca ~ my current site . . info@digitalinsite.ca ~ my email

    If you feel that someone's post helped you fix your problem, answered your question, or just made you feel better, feel free to "Like" their post. The "Like" link is at the bottom right of each post, along side the "reply" link. And if you are being helped here, try to help someone else - pass it on!

  9. #8
    Banned
    Join Date
    May 2011
    Location
    Fairfax, CA
    Posts
    2,036
    Member #
    28003
    Liked
    126 times
    no that AM, is cPanel's error message creator!
    It's really stupid, I know, lol. I think you're better off just making the page yourself.

  10. #9
    WDF Staff AlphaMare's Avatar
    Join Date
    Oct 2009
    Location
    Montreal, Canada
    Posts
    4,570
    Member #
    20277
    Liked
    878 times
    Quote Originally Posted by shovenose, post: 214958
    no that AM, is cPanel's error message creator!
    It's really stupid, I know, lol. I think you're better off just making the page yourself.
    Thanks for that - I hardly ever use cPanel - I code my own error pages and upload thru FileZilla.
    Good design should never say "Look at me!"
    It should say "Look at this." ~ David Craib


    http://digitalinsite.ca ~ my current site . . info@digitalinsite.ca ~ my email

    If you feel that someone's post helped you fix your problem, answered your question, or just made you feel better, feel free to "Like" their post. The "Like" link is at the bottom right of each post, along side the "reply" link. And if you are being helped here, try to help someone else - pass it on!


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:10 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com