The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Custom 404 pages per site

Discussion in 'General Discussion' started by Sillysoft, Jun 18, 2011.

  1. Sillysoft

    Sillysoft Member

    Joined:
    Jun 5, 2009
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    Using Cpanel I have one main account and a bunch of add on domains under that account. What I want to do is be able to provide custom 404 pages per site. Some sites I want it to actually redirect them to the home page of that site, for others I would like to display a custom 404 page. How would I go about doing that?

    So one site if they go to www.site1.com/somepage.html and somepage.html is not there I want it to redirect to www.site1.com
     
  2. tank

    tank Well-Known Member

    Joined:
    Apr 12, 2011
    Messages:
    236
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Chicago, IL
    cPanel Access Level:
    Root Administrator
    Sounds like your mixing 301 redirects and 404 error pages. Cpanel however does have a section on the user end that allows the creation of the error pages for you.
     
  3. Sillysoft

    Sillysoft Member

    Joined:
    Jun 5, 2009
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    No dont want a 301 redirect. I want a 404 error to redirect back to the home page of the site. I can do that via htaccess but some sites I want just regular 404 pages and some sites I want it to redirect back to the home page of the site if a 404 error happens.
     
  4. tank

    tank Well-Known Member

    Joined:
    Apr 12, 2011
    Messages:
    236
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Chicago, IL
    cPanel Access Level:
    Root Administrator
    So make an html page and copy all of your code expect the content section. Put
    Code:
    <h2>404 Error page</h2>
            <p><!--#echo var="REQUEST_URI" -->  does not exist. <a href="#" class="und"><strong></strong></a>Please check that address and try again.  </p>.
    Boom you have a 404 page that looks exactly as your home page.

    I am sorry if I am not understanding what you are asking. As for the 404 page the redirects to another page, I am unsure as to how to accomplish that.

    Use caution with these error pages, because if not done properly you can get penalized by the search engine for having duplicate content.
     
  5. cPanelTristan

    cPanelTristan Quality Assurance Analyst
    Staff Member

    Joined:
    Oct 2, 2010
    Messages:
    7,623
    Likes Received:
    21
    Trophy Points:
    38
    Location:
    somewhere over the rainbow
    cPanel Access Level:
    Root Administrator
    If someone reaches a non-existent page, they should know they reached the wrong page. While you could have a link back to the home page on your custom 404 page, I do not suggest simply redirecting back to the home page with it unless it is going to do so on a time delay after informing the user that the page doesn't exist.

    If you do want to follow that direction to at least inform the user, then you can use a meta refresh in HTML to do this using cPanel > Error pages > 404 (not found) and putting the following content:

    Code:
    <HTML>
    <HEAD>
    <META HTTP-EQUIV="refresh" CONTENT="15;http://domain.com">
    </HEAD>
    <BODY>
    This page is not found. You will be redirected in 15 seconds to the main site.
    </BODY>
    </HTML>
    Upon adding that content, you will need to change domain.com to the actual domain name. This works perfectly well on my test site:

    http://tristanwallace.com/notfound

    You could also change 15 seconds to whatever interval you prefer in both the META tag and the BODY area.
     
Loading...

Share This Page