Link to home
Start Free TrialLog in
Avatar of hcaadev
hcaadevFlag for United States of America

asked on

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.
Avatar of Brad Howe
Brad Howe
Flag of Canada image

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
Avatar of hcaadev

ASKER

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.
K, I am testing it now in my VM. I'll let you know shortly.

Cheers,
Hades666
ASKER CERTIFIED SOLUTION
Avatar of Brad Howe
Brad Howe
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hcaadev

ASKER

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.

Cool. Thanks for the point and happy you got it working. This has been added to my knowledge base. - Hades666