How to check if website is available when redirection is enabled

Solution 1:

Just using -L solved my problem So now using

echo $(curl -L mysubhost.com --write-out '%{http_code}' --silent --output /dev/null servername)

will follow the redirection and return the final response code, and based on which you can make your decisions.