404 and Redirect Question

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

Offline manvbfTopic starter

  • Full Member
  • ***
  • Posts: 123
  • Karma: 1
404 and Redirect Question
« on: 10-29-2011, 05: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

  • Semi-Newbie
  • *
  • Posts: 10
  • Karma: 1
  • Gender: Male
    • http://www.freeplusaccounts.co.uk/
Re: 404 and Redirect Question
« Reply #1 on: 11-07-2011, 23: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

  • Sr. Member
  • ****
  • Posts: 360
  • Karma: 2
  • Gender: Male
Re: 404 and Redirect Question
« Reply #2 on: 11-09-2011, 08: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

  • Semi-Newbie
  • *
  • Posts: 11
  • Karma: 1
Re: 404 and Redirect Question
« Reply #3 on: 01-18-2012, 07:46:53 »
I think it's good idea to redirect 404 page to home page after some seconds.

Offline smith

  • Full Member
  • ***
  • Posts: 105
  • Karma: 2
Re: 404 and Redirect Question
« Reply #4 on: 01-19-2012, 01: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
633 Views
Last post 03-23-2012, 04:02:34
by richard branson
1 Replies
693 Views
Last post 06-05-2010, 11:35:33
by ryosuzuki
2 Replies
285 Views
Last post 08-16-2011, 10:35:42
by takeshiro
2 Replies
102 Views
Last post 10-13-2011, 08:29:22
by C.Rebecca
13 Replies
310 Views
Last post 05-21-2012, 07:53:17
by stevensmith