Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8617851
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:57:58+00:00 2026-06-12T05:57:58+00:00

I am trying to capture the URL that produced a routing error. My end

  • 0

I am trying to capture the URL that produced a routing error. My end goal is the change the domain on the URL to check if it exists on our old site (changed the domain) and if so redirect to the old site. Here is what I have do far.

unless Rails.application.config.consider_all_requests_local
  rescue_from Exception, with: :render_500
  rescue_from ActionController::RoutingError, with: :check_old_site
  rescue_from ActionController::UnknownController, with: :render_404
  rescue_from ActionController::UnknownAction, with: :render_404
  rescue_from ActiveRecord::RecordNotFound, with: :render_404
end

private

def check_old_site(exception)
  #Need to edit the URL but I need access to before I can write the code to modify
  captured_and_modified_url = ???
  case Net::HTTP.get_response(URI.parse(captured_and_modified_url)) 
    when Net::HTTPSuccess then redirect_to captured_and_modified_url
    else render_404(exception)
  end
end

def render_404(exception)
  @not_found_path = exception.message
  respond_to do |format|
    format.html { render template: 'errors/error_404', layout: 'layouts/application', status: 404 }
    format.all { render nothing: true, status: 404 }
  end
end

So for this question I just want to get at the URL that got to 404 error. Thanks for any help up front.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:58:00+00:00Added an answer on June 12, 2026 at 5:58 am

    Figure this out a while ago. request.path

    def check_old_site(exception)
      exception_url = "http://old.richarddawkins.net#{request.path}"
      case Net::HTTP.get_response(URI.parse(exception_url))
        when Net::HTTPSuccess then redirect_to exception_url
        else render_404(exception)
      end 
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to capture a session ID from a URL so that the
I'm trying to get create a capture template that converts an URL to an
I'm trying to capture the screen whenever something goes wrong, either an error or
I'm trying to capture http request that occurs in a callback function : //
I am trying to capture urls in an html page that is being repeated
I'm using code igniter and am trying to capture multiple url segments via the
I am trying to build a pixel that would track the current URL the
I'm trying to create a regex that will capture BB Codes, BB Codes with
I have a URL that resides on another domain, like this: http://ads.adserver.com/ad?site=1233&zone=45435 When you
What I'm trying to do: Create a home page on our company's intranet that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.