Jump to content

Recommended Posts

You could make a custom 404 error page, set its location in your .htaccess file, and then put a redirect on that page . I do this on my website using javascript, because I like the user to know they had a 404 error. The redirect waits 10 or 15 seconds before redirecting, and that 10 or 15 seconds is counted down on screen. Try it, I think you'll like it.

so...why do you make your visitors sit around on the 404 screen that long?  personally, I hate it when websites do that. 

 

They can go anywhere they want. The 404 page has all of the normal menus of the site. It also has a link for them if they don't want to wait for the redirect.

I did it from cpanel and it work with firefox but not IE or chrome

 

the .htaccess is as follow

 

# Use PHP5 as default

AddHandler application/x-httpd-php5 .php

 

RemoveHandler .html .htm

AddType application/x-httpd-php .php .htm .html

 

I know that there is no ErrorDocument but there is file 404.shtml and it work !!

 

please advice

 

thanks

ErrorDocument 404 /index.htm

 

Or within any page

 

function redirect( $url ){
    if (! headers_sent( ) ){
    
        header( "Location: ".$url );
        exit( 0 );
    }
    echo "<script language=Javascript>document.location.href='".$url."';</script>";
    exit( 0 );
}

The htaccess option is the best

 

ErrorDocument 404 /index.htm

 

If your just using it to redirect wrong urls htaccess will do it for you, but if you really want to you can do it this way

 

ErrorDocument 404 /error.php

 

And in error.php

 

function redirect( $url ){
    if (! headers_sent( ) ){
   
        header( "Location: ".$url );
        exit( 0 );
    }
    echo "<script language=Javascript>document.location.href='".$url."';</script>";
    exit( 0 );
}

redirect("http://site.com/"); //redirect anywhere you want

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.