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 6093041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:30:52+00:00 2026-05-23T12:30:52+00:00

If my website is www.foo.com if the user types www.foo.com/blahblahblah it will say that

  • 0

If my website is www.foo.com if the user types www.foo.com/blahblahblah it will say that /blahblahblah is an invalid path (obviously). But I want it instead to redirect to the root_path so that the controller can process the URL — the page www.foo.com should be rendered I want to pull the text blahblahblah and do something with it. How do I do this?

  • 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-05-23T12:30:53+00:00Added an answer on May 23, 2026 at 12:30 pm

    There are several possibilities. Here’s one. You could add this to the bottom of your routes.rb:

    match ':not_found' => 'my_controller#index',
      :constraints => { :not_found => /.*/ }
    

    which will establish a catch-all route to make MyController’s index action handle any missing paths; it can detect them by looking at params[:not_found] and doing whatever it wants, such as redirecting to the root_path (redirect_to root_url), redirecting somewhere strategically based on the bad path, rendering something special, examining the referrer/referer for clues about the source, etc.

    The :constraints option is necessary; otherwise the not_found param won’t be able to contain special characters like slashes and dots.

    Put this at the bottom of your routes because, obviously, it will match everything, and you want to give your other routes first crack at the path.

    If you only want to redirect, nothing more, you could do this instead (again, at the bottom):

    match ':not_found' => redirect('/'), :constraints => { :not_found => /.*/ }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I visit 1 website www.abc.com that has a reference to say jQuery hosted
I'm working on a website (say, www.domain.com ) and want to release part of
I have a website www.askvioletnow.com. I added a flash mp3 player that plays a
I am using a webbrowser control to login to a website. WbBrowser.Navigate(http://www.foo.com/login.php) Once the
Actually in my website www.musicking.in when the user selects songs one player window will
Actually in my website www.musicking.in when the user selects songs one player window will
Actually in my website www.musicking.in when the user selects songs one player window will
Let's assume I have a website www.mywebsite.com . I have a folder named foo
I made the following website: www.appliedintelligentmarketing.com It works fine in all browsers but I've
Say I have a website www.abc123.com. What would be the best way to determine

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.