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

  • SEARCH
  • Home
  • 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 6376295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:43:34+00:00 2026-05-25T01:43:34+00:00

My users submit urls (to mixes on mixcloud.com) and my app uses them to

  • 0

My users submit urls (to mixes on mixcloud.com) and my app uses them to perform web requests.

A good url returns a 200 status code:

uri = URI.parse("http://www.mixcloud.com/ErolAlkan/hard-summer-mix/")
request = Net::HTTP.get_response(uri)(
#<Net::HTTPOK 200 OK readbody=true>

But if you forget the trailing slash then our otherwise good url returns a 301:

uri = "http://www.mixcloud.com/ErolAlkan/hard-summer-mix"
#<Net::HTTPMovedPermanently 301 MOVED PERMANENTLY readbody=true> 

The same thing happens with 404’s:

# bad path returns a 404
"http://www.mixcloud.com/bad/path/" 
# bad path minus trailing slash returns a 301
"http://www.mixcloud.com/bad/path"
  1. How can I ‘drill down’ into the 301 to see if it takes us on to a valid resource or an error page?
  2. Is there a tool that provides a comprehensive overview of the rules that a particular domain might apply to their urls?
  • 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-25T01:43:34+00:00Added an answer on May 25, 2026 at 1:43 am

    301 redirects are fairly common if you do not type the URL exactly as the web server expects it. They happen much more frequently than you’d think, you just don’t normally ever notice them while browsing because the browser does all that automatically for you.

    Two alternatives come to mind:

    1: Use open-uri

    open-uri handles redirects automatically. So all you’d need to do is:

    require 'open-uri' 
    ...
    response = open('http://xyz...').read
    

    If you have trouble redirecting between HTTP and HTTPS, then have a look here for a solution:
    Ruby open-uri redirect forbidden

    2: Handle redirects with Net::HTTP

    def get_response_with_redirect(uri)
       r = Net::HTTP.get_response(uri)
       if r.code == "301"
         r = Net::HTTP.get_response(URI.parse(r['location']))
       end
       r
    end
    

    If you want to be even smarter you could try to add or remove missing backslashes to the URL when you get a 404 response. You could do that by creating a method like get_response_smart which handles this URL fiddling in addition to the redirects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my rails app I'd like to let users submit custom themes to display
I'm writing a web application where users can submit pictures, videos, and descriptons of
I'm working on an app that will let users submit zip files that are
I allow users to submit a query at mysite.com/go/QUERY\ If the query contains /
I am working on a project where I will let users submit small 'scripts'
I use a php form processor script that works fine. Except when users submit
Am currently working on an application that requires users to submit posts and comments
I would like to give points to my users who submit articles based on
I'm currently working on a ticketing system which allows our users to submit tickets
I have a form which users must fill out and submit. The controller action

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.