6

I have a server with a lot of domain redirections that I want to check.

I do not trust the way browsers cache the domains so I am never sure if I am seeing it live or seeing a redirection from cache.

Is there a way to test the redirection from terminal and seeing the real thing without any kind of cache?

I have tried

curl -I http://example.com

as stated by other posts but it is not providing any important information on my Mac.

It gives me this:

HTTP/1.1 406 Not Acceptable
Date: Mon, 29 Jan 2018 18:26:50 GMT
Server: Apache
Content-Type: text/html; charset=iso-8859-1
1
  • Fix whatever's causing the 406, likely not sending an acceptable content type, method, and request body combination. Chrome dev tools has a copy request as curl feature: visit the page in browser, then copy as curl for a starting point.
    – bishop
    Jan 29, 2018 at 19:40

1 Answer 1

8

curl has the -L option

-L, --location (HTTP) If the server reports that the requested page has moved to a different location (indicated with a Location: header and a 3XX response code), this option will make curl redo the request on the new place ...

Therefore you could use curl -L example.com which should give the document after all redirects.

Additionally, you can supply the verbose flag -v which will state that it is being redirected.

4
  • not working for me. It gives me this <html><head><title>Error 406 - Not Acceptable</title><head><body><h1>Error 406 - Not Acceptable</h1><p>Generally a 406 error is caused because a request has been blocked by Mod Security. If you believe that your request has been blocked by mistake please contact the web site owner.</p></body></html>
    – Duck
    Jan 29, 2018 at 18:45
  • A 4xx HTTP status code is a client error. If the server wants the client to redirect, it should use a 3xx status code. Many clients don't expect to continue looking for a document when they're told there's an error with their request.
    – Torin
    Jan 29, 2018 at 18:48
  • all redirects have code 301
    – Duck
    Jan 29, 2018 at 18:49
  • Which yours does not. "3xx Redirection - This class of status code indicates the client must take additional action to complete the request. Many of these status codes are used in URL redirection." - List of HTTP status codes
    – Torin
    Jan 29, 2018 at 18:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .