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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:54:55+00:00 2026-06-06T21:54:55+00:00

I am developing an application in rails which requires checking whether a sitemap of

  • 0

I am developing an application in rails which requires checking whether a sitemap of the entered website’s URL exists or not? For Eg if a user enters http://google.com then it should return “Sitemap present”.I have seen for solutions that usually websites have either /sitemap.xml or /sitemap at the end of their URL.So i tried putting a check for this using typhoeus gem, checking response.code for the URL(like http://www.google.com/sitemap.xml OR http://www.apple.com/sitemap) that if it returns with a 200 or 301, then sitemap exists, else not.But i have found that some sites return a 301 even if they dont have a sitemap, they redirect it to their main page(For Eg http://yournextleap.com/sitemap.xml), hence i don’t get a conclusive result.Any help would be really great.
Here is my sample code to check for sitemap using typhoeus :

# the request object
request = Typhoeus::Request.new("http://apple.com/sitemap")

# Run the request via Hydra.
hydra = Typhoeus::Hydra.new

request.on_complete do |response|
  if response.code == 301
   p "success 301" # hell yeah
   elsif response.code == 200
    p  "Success 200"
   elsif response.code == 404
.   puts "Could not get a sitemap, something's wrong."  
    else
    p "check your input!!!!"
end 
  • 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-06T21:54:59+00:00Added an answer on June 6, 2026 at 9:54 pm

    The HTTP response status code 301 Moved Permanently is used for
    permanent redirection. This status code should be used with the
    location header. RFC 2616 states that:

    If a client has link-editing capabilities, it should update all references to the Request URI.
    The response is cachable.
    Unless the request method was HEAD, the entity should contain a small hypertext note with a hyperlink to the new URI(s).
    If the 301 status code is received in response to a request of any type other than GET or HEAD, the client must ask the user before redirecting.
    

    I don’t think its fair for you to assume that a 301 Response indicates that there was ever a sitemap. If you’re checking the existence of a sitemap.xml or a sitemap directory then the correct response to expect is a 2XX.

    If you’re insistent on assuming that a 3XX request indicates a redirect to a sitemap, then follow the redirect and add logic to check the url of the page (if its the homepage) or the content of the page to see if it has XML structure.

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

Sidebar

Related Questions

I am developing an application in rails which requires to check whether the entered
I am developing a rails application in which I have two models User and
I'm developing a new rails application which is supposed to be installed several times
I'm developing a Ruby on Rails application that needs to allow the user to
I am developing a Rails application which will need frequent access to public APIs,
I have a Ruby on Rails application that I'm developing on my computer, which
I am developing a Rails 3 application (which acts as an API) and I
I am developing a Rails 3 application from which I want to be able
I am developing a rails application which should send push notifications to iOS devices.
I am developing Ruby on Rails application which uses Thinking Sphinx. Unfortunately, from time

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.