How to check if the user is visiting the site’s root url?
The easiest JavaScript method is: var is_root = location.pathname == “https://stackoverflow.com/”; //Equals true if we’re at the root Even http://example.com/?foo=bar#hash will produce the right result, since the pathname excludes the query string and location hash. Have a look: http://anything-but-a-slash/ Root /?querystring Root /#hash Root /page Not root If you have index file(s) at your root … Read more