Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSamuel Fortunato
20,229 Points301 Error? (SOLVED: Don't type "www" in URL?!)
Getting a 301 error upon requesting https://teamtreehouse.com/chalkers.json . Same as when I try it on my own username. When I try to log out the response's status code, I get 301.
Any ideas?
EDIT: Nevermind. I was getting a 301 error when I typed "www" in the URL when I typed https.get().
For whatever reason, that doesn't work? I took out the "www" and got a 200 status code, indicating that it worked fine. But with the "www", I get a 301 status code. Why?
1 Answer
Steven Parker
231,275 PointsA 301 isn't exactly an error, it's a status code informing the requester that what you're looking for has been moved and should be retrieved from a different URL. The correct one to use is included in the returned header as "Location".
Had you been using a browser, the page would've been retried at the new URL automatically.
Samuel Fortunato
20,229 PointsSamuel Fortunato
20,229 PointsIs there a specific reason why the URL doesn't work when I type in www? Seems strange to me.
Steven Parker
231,275 PointsSteven Parker
231,275 PointsProviders may re-organize their site and want to maintain compatibility with previous URL's, or they may have other reasons to provide the same page when requested multiple ways. Just one of the possible addresses will be the "real" one, and the rest will issue redirect messages like this one.
Samuel Fortunato
20,229 PointsSamuel Fortunato
20,229 PointsGotcha. Thank you :)