Search code examples
nginxurlurl-rewritingrequesttrailing-slash

Homepage with "/" at the end


Let's say I have a site with URL: example.com
Does Google is treating "example.com" and "example.com/" pages as separate - So google thinks that one of them are duplicate?
If so, is it possible to configure 301 redirects from “example.com” to “example.com/” with a slash at the end?


Solution

  • example.com is not an URL, it is a domain name, hostname, or website name depending on how you look at it.

    An URL would be http://example.com/. You could write it as http://example.com if you want, but if you try in your browser you will see it gets rewritten immediately as http://example.com/.

    Because when the browser connects to an HTTP server it sends a query like this:

    GET / HTTP/1.1
    Host: example.com
    

    The thing after GET is the path, and it can not be empty. So it needs to be at least /, the root of the website.