Custom 404 Error Messages - Multiple Domains - Go Daddy

Hi,

I have a Windows shared hosting account with GoDaddy.  I run multiple sites on this account and I need to be able to have custom 404 error page for each domain.  I do not run ASP.NET websites.  I just run static HTML or ASP Classic websites.  My plan has the ability to run php.  Are there any options out there?  I can setup only 1 custom 404 Error page per hosting account.
hcaadevAsked:
Who is Participating?
 
Brad HoweConnect With a Mentor DevOps ManagerCommented:
This code works great. I have just tested it.

Essentially, the previous posted code "(strpos($ref, "blog.mydomain.com"))" never validates so it is all the ELSE condition.

The $ref is always the income requested url. Wether that be localhost, www.dummysite1.com, www.domain.org. In the end this 404 check the refferal URL and redirects appropriately.

404.php
----------

<?php
$ref = $_SERVER['SERVER_NAME'];

if($ref == "www.dummysite1.com")
{header( 'Location: http://www.dummysite1.com/errorpage' );}

elseif($ref == "www.dummysite2.com")
{header( 'Location: http://www.dummysite2.com/errorpage' );}

else
{header( 'Location: http://domain.com/errorpage' );}

?>

-----------------

Hope it helps,
Hades666
0
 
Brad HoweDevOps ManagerCommented:
Hi,

PHP will do this for you. You essentially create a custom 404 page for you main www.domain.com and put in header referencing information to redirect.

ex: custom_404.php
========
$ref = $_SERVER['SERVER_NAME'];
if(strpos($ref, "otherdomain.com"))
{
header( 'Location: http://otherdomain.com/errorpage' ) ;
}
elseif(strpos($ref, "blog.mydomain.com"))
{
header( 'Location: http://blog.mydomain.com/errorpage' ) ;
}
else
{
header( 'Location: http://www.domain.com/error/' ) ;
}
=======

Source:
http://blog.justinkorn.com/2009/12/custom-404-page-on-windows-shared-hosting/

Cheers,
Hades666
0
 
hcaadevAuthor Commented:
Hi Hades666,

I believe this is the same one I found earlier but I think I go the syntax wrong.  I will test and let you know.
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
Brad HoweDevOps ManagerCommented:
K, I am testing it now in my VM. I'll let you know shortly.

Cheers,
Hades666
0
 
hcaadevAuthor Commented:
I did find this same script but I am not a php programmer so I was missing some things.  Your answers helped me complete the code needed.  Thanks for your help!!  Works fine on my side and actually I was able to program this same idea with asp with a case select.

domain = Request.ServerVariables("SERVER_NAME")

Select Case domain
      Case "www.domain1.com"
            Response.Redirect("http://www.domain1.com/errorpage")
      Case "domain1.com"
            Response.Redirect("http://www.domain1.com/errorpage")
      Case "www.domain2.com"
            Response.Redirect("http://www.domain2.com/errorpage")
      Case "domain2.com"
            Response.Redirect("http://www.domain2.com/errorpage")
      
      Case Else
            Response.Redirect("http://www.rootdomain.com/errorpage")
End Select      


Something like this.  But this works as well as the php.  I will stick with the asp since this is what I know.

0
 
Brad HoweDevOps ManagerCommented:
Cool. Thanks for the point and happy you got it working. This has been added to my knowledge base. - Hades666
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.