Search code examples
http-redirectdnsgithub-pagesnamecheap

Page on custom domain gives "too many redirects" error


I have a domain from Namecheap.com and hosted a page through github pages. Sometimes the my page fails to load and gives "too many redirects" error. I think the problem in somewhere in my advanced DNS. Take a look at it-enter image description here

Basically I have got 2 A records pointing to the IP address of Github and a CNAME record pointing to mygithubusername.github.io and an URL redirect record pointing to my domain. What am I doing wrong?


Solution

  • As far as I can see the problem comes from the URL redirect record. When trying to reach www.akshayud.me it redirects to akshayud.me and when it hit the URL redirect it redirects back to www.akshayud.me, which redirects to akshayud.me and is making an infinite loop.

    To solve it remove the URL record from the DNS (which is my preferred solution) or fix the redirection from www to root on web server level. Here is my wget output (I used only the URL record IP to guaranty 100% usage of the URL redirect record):

    $ wget www.akshayud.me
    
    --2017-12-19 08:03:18--  http://www.akshayud.me/
    Resolving www.akshayud.me (www.akshayud.me)... 151.101.1.147, 151.101.65.147, 151.101.129.147, ...
    Connecting to www.akshayud.me (www.akshayud.me)|151.101.1.147|:80... connected.
    HTTP request sent, awaiting response... 301 Moved Permanently
    Location: http://akshayud.me/ [following]
    
    --2017-12-19 08:03:18--  http://akshayud.me/
    Resolving akshayud.me (akshayud.me)... 162.255.119.148
    Connecting to akshayud.me (akshayud.me)|162.255.119.148|:80... connected.
    HTTP request sent, awaiting response... 302 Found
    Location: http://www.akshayud.me/ [following]
    
    --2017-12-19 08:03:18--  http://www.akshayud.me/
    Connecting to www.akshayud.me (www.akshayud.me)|151.101.1.147|:80... connected.
    HTTP request sent, awaiting response... 301 Moved Permanently
    Location: http://akshayud.me/ [following]
    
    --2017-12-19 08:03:18--  http://akshayud.me/
    Connecting to akshayud.me (akshayud.me)|162.255.119.148|:80... connected.
    HTTP request sent, awaiting response... 302 Found
    Location: http://www.akshayud.me/ [following]
    
    --2017-12-19 08:03:19--  http://www.akshayud.me/
    Connecting to www.akshayud.me (www.akshayud.me)|151.101.1.147|:80... connected.
    HTTP request sent, awaiting response... 301 Moved Permanently
    Location: http://akshayud.me/ [following]