Sillysoft

Member
Jun 5, 2009
13
0
51
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
 

tank

Well-Known Member
Apr 12, 2011
255
5
68
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.
 

Sillysoft

Member
Jun 5, 2009
13
0
51
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.
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.
 

tank

Well-Known Member
Apr 12, 2011
255
5
68
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.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
43
348
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.