404 and Redirect Question

Author Topic: 404 and Redirect Question  (Read 1438 times)

Offline manvbfTopic starter

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 1
  • Posts: 123
  • Karma: 1
404 and Redirect Question
« on: 10-29-2011, 03:46:16 »
So I have the custom error pages set up and working fine, but I was just thinking of adding a META refresh that redirects to the site home page after 30 seconds or so. Has anyone tried this? Will the SEs be OK with this? Or will they think I'm "up to something"...?

Thanks!


Offline freeplusac

  • Trade Count: (0)
  • Semi-Newbie
  • *
  • Thank You 0
  • Posts: 10
  • Karma: 1
  • Gender: Male
    • http://www.freeplusaccounts.co.uk/
Re: 404 and Redirect Question
« Reply #1 on: 11-07-2011, 21:35:50 »
hi

 Don't render 404 yourself, there's no reason to; Rails has this functionality built in already. If you want to show a 404 page, create a render_404 method (or "not_found" as I called it) in ApplicationController like this:

def not_found
  raise ActionController::RoutingError.new('Not Found')
end

Rails also handles AbstractController::ActionNotFound, and ActiveRecord::RecordNotFound the same way.

This does two things better:

1) It uses Rails' built in rescue_from handler to render the 404 page, and 2) it interrupts the execution of your code, letting you do nice things like:

  user = User.find_by_email(params[:email]) || not_found
  user.do_something!

without having to write ugly conditional statements.

As a bonus, it's also super easy to handle in tests. For example, in an rspec integration test:

lambda {
  visit '/something/you/want/to/404'
}.should raise_error(ActionController::RoutingError)


Offline takeshiro

  • Trade Count: (0)
  • Sr. Member
  • ****
  • Thank You 10
  • Posts: 357
  • Karma: 2
  • Gender: Male
    • JavaScript Editor
Re: 404 and Redirect Question
« Reply #2 on: 11-09-2011, 06:11:18 »
i agree that there is no reason for you to make a 404 page. there's, like, a default for that.

Offline eetplus

  • Trade Count: (0)
  • Semi-Newbie
  • *
  • Thank You 0
  • Posts: 16
  • Karma: 1
Re: 404 and Redirect Question
« Reply #3 on: 01-18-2012, 05:46:53 »
I think it's good idea to redirect 404 page to home page after some seconds.
Elan - Web & Mobile Application Development Company

Offline smith

  • Trade Count: (0)
  • Full Member
  • ***
  • Thank You 0
  • Posts: 103
  • Karma: 2
Re: 404 and Redirect Question
« Reply #4 on: 01-18-2012, 23:12:38 »
Hi,
404 redirect of the website make it crawler friendly, otherwise there will be chances that the trust-ability of the site may decreased.
This will also increase the bounce rate of the site, try to avoid it.
I am feeling PROUD to be a member of SEOMASTERING.  !-!


 

Related Topics

  Subject / Started by Replies Last post
3 Replies
2245 Views
Last post 12-05-2014, 00:25:10
by Stephen
6 Replies
2616 Views
Last post 08-23-2016, 09:03:49
by RH-Calvin
1 Replies
777 Views
Last post 02-06-2017, 22:26:49
by wellliving
0 Replies
723 Views
Last post 04-08-2015, 14:44:11
by grinka
7 Replies
2762 Views
Last post 03-03-2016, 03:49:33
by Shikha Singh