Results 1 to 11 of 11

Thread: Set Up a 404 Redirect?

  1. #1
    Moderator Bec's Avatar
    Join Date
    Nov 2003
    Location
    Ohio
    Posts
    8,419

    Set Up a 404 Redirect?

    I can't find what piece of htaccess code I need to put on an htaccess to have my 404 errors redirect to another url automatically. Anyone got it handy?


  2. #2
    Jesus was never married, ran around with twelve guys, and was betrayed by a kiss from another guy. Lippi's Avatar
    Join Date
    Oct 2005
    Location
    Amsterdam
    Posts
    304
    Redirect /error_pages/404.html / http://www.yourdomain.com/new_dir/index.html

    Hope that helps.
    Have a nice day,
    Lippi :morning:

    www.thebestboys.com


  3. #3
    Gay Marriage - It's our Pearl Harbor.
    Join Date
    Dec 2008
    Location
    Buenos Aires, Argentina
    Posts
    64
    ErrorDocument 404 /directory/filename.ext

    you might want to automatically send them back to your home page so you could do something like this (change .PHP to .HTM, .HTML, or whatever is your default extension):

    ErrorDocument 404 /index.php

    Kevin


  4. #4
    Jesus was never married, ran around with twelve guys, and was betrayed by a kiss from another guy. Lippi's Avatar
    Join Date
    Oct 2005
    Location
    Amsterdam
    Posts
    304
    Quote Originally Posted by vaqueros View Post
    ErrorDocument 404 /directory/filename.ext

    you might want to automatically send them back to your home page so you could do something like this (change .PHP to .HTM, .HTML, or whatever is your default extension):

    ErrorDocument 404 /index.php

    Kevin
    Kevin, this is to call the error document only.
    Have a nice day,
    Lippi :morning:

    www.thebestboys.com


  5. #5
    Jesus was never married, ran around with twelve guys, and was betrayed by a kiss from another guy. Lippi's Avatar
    Join Date
    Oct 2005
    Location
    Amsterdam
    Posts
    304

    htaccess-guide

    Now I found the link I was looking for:

    http://www.htaccess-guide.com/

    There you will find all about .htaccess
    Have a nice day,
    Lippi :morning:

    www.thebestboys.com


  6. #6
    Gay Marriage - It's our Pearl Harbor.
    Join Date
    Dec 2008
    Location
    Buenos Aires, Argentina
    Posts
    64
    Quote Originally Posted by Lippi View Post
    Redirect /error_pages/404.html / http://www.yourdomain.com/new_dir/index.html

    Hope that helps.
    That's actually kind of a double-redirect. Somewhere in .htaccess or elsewhere in the Apache configuration, there has to be an order to send 404 errors to "/error_pages/404.html" or else the browser will simply display it's default 404 Page Not Found message because it has no instructions from Apache to look for an error page. But assuming that the redirect order does exist, it sends it to "/error_pages/404.html" but before it even arrives there Apache will send it off again to "http://www.yourdomain.com/new_dir/index.html". So it ends up being redirected twice.

    Using ErrorDocument ### (for 404 or any other numeric error code) should be used to send the user where you want him/her to go. If it's a custom error page saying "Sorry, can't find that, please click here to go to our home page" or if you want to send them directly to the home page without notice, you can code it either way.

    Generally it's best to use relative URLs in these cases, in case you ever move your site to another domain. So /mycustomerrorpage.htm is better than http://mydomain.com/mycustomerrorpage.htm.

    Be very cautious about using ErrorDocument rules with Apache rewrite or redirect rules in .htaccess. If you don't know what you're doing, you can end up in an endless loop where Apache sends the user to an error page which has its URL rewritten to a non-existent page (error) which sends the user to an error page .... you get the idea.

    Kevin


  7. #7
    Jesus was never married, ran around with twelve guys, and was betrayed by a kiss from another guy. Lippi's Avatar
    Join Date
    Oct 2005
    Location
    Amsterdam
    Posts
    304
    Ok Kevin, I get it. Thanks for making things more clear.

    Btw, I use custom 404 pages with revshare links.

    Also a nice idea is to give the visitor the choice where to go in a given time and redirect the page to where you like in this given time. But sure, it depends all of your reasons and plans what and how to do. $0.02

    So Bec, I hope you will find the right solution.
    Have a nice day,
    Lippi :morning:

    www.thebestboys.com


  8. #8
    Moderator Bec's Avatar
    Join Date
    Nov 2003
    Location
    Ohio
    Posts
    8,419
    Thanks guys for such informative answers! You rock!

    Lippi, do I just use my embedded code link as the forward to url to get credit on a redirect? Been meaning to ask if that's doable and if you still get credit for any sales by doing that.


  9. #9
    Jesus was never married, ran around with twelve guys, and was betrayed by a kiss from another guy. Lippi's Avatar
    Join Date
    Oct 2005
    Location
    Amsterdam
    Posts
    304
    I guess it's doable, Bec. But be careful, I guess some programs doesn't allow promoting with redirects. Check their terms first.
    I don't use redirects with my 404 page. I put some links on it, only.
    Just check it out here: www.thebestboys.com/kedkeh/
    Have a nice day,
    Lippi :morning:

    www.thebestboys.com


  10. #10
    Moderator Bec's Avatar
    Join Date
    Nov 2003
    Location
    Ohio
    Posts
    8,419
    Quote Originally Posted by Lippi View Post
    I guess it's doable, Bec. But be careful, I guess some programs doesn't allow promoting with redirects. Check their terms first.
    I don't use redirects with my 404 page. I put some links on it, only.
    Just check it out here: www.thebestboys.com/kedkeh/
    That's a nice 404 page. I've done something similar in the past with some of my sites, but a suggestion from Patti was to take and send my 404's to my review site, so thought I'd try that for awhile and see how it does.


  11. #11
    Jesus was never married, ran around with twelve guys, and was betrayed by a kiss from another guy. Lippi's Avatar
    Join Date
    Oct 2005
    Location
    Amsterdam
    Posts
    304
    It's a good idea to send it to your preview site. I guess this will work fine. Good luck with this!
    Have a nice day,
    Lippi :morning:

    www.thebestboys.com


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •