The website URL is http://example.com but some pages have been redirected to http://example.com/, the version of the URL with the trailing slash. Should I change all redirects to the non-trailing-slash URL?

  • Are you talking about the trailing slash on the home page (the root of the domain) without any extra path? The situation for that (http://example.com vs http://example.com/) is different than for a directory (/folder vs /folder/). – Stephen Ostermiller Oct 16 '18 at 12:46
  • Actually it is the homepage not subfolder – Maryam Beheshti Oct 16 '18 at 13:46
  • 1
    Launch some developer tools inside your browser, and inspect the HTTP request being done. Even if you type just a name or an "URL" like http://example.com you will see that your browser sends in fact a GET / request, so at least a / is mandatory to say "root". – Patrick Mevzek Oct 16 '18 at 14:57
  • Yes, as Patrick suggests, don't just look at the "beautified" URL in the browser's address bar. Browser's notoriously "beautify" the public URL seen in the browser - more so these days than they ever did. See also: webmasters.stackexchange.com/questions/35643/… – MrWhite Oct 16 '18 at 17:22
  • not really matter for redirect in q if done corecct but redirect technique also matters, for example doing apache redirect without trailing slash will most probably fail if original request came with path like example.com/foo. it will redirect to invalid example.comfoo – Sampo Sarrala - codidact.org Nov 3 '18 at 3:07
  • Homepage: Google has stated that the homepage doesnt really matter if there is or isnt a trailing slash.

  • Directory: directories must have a trailing slash in the end.

  • File/Page: an html page or an file shouldn't have a trailing slash.

| improve this answer | |
  • 2
    It's not just Google. When it comes to the home page, the HTTP spec states that there is no difference between having a trailing slash and not having one. Whether or not the slash shows in the URL, the HTTP request must include the slash. – Stephen Ostermiller Oct 16 '18 at 14:51
  • Note example.com/index.php are the same as example.com/index.php/something at least for apache. You can process this trailing uri in index.php, making possible to use different urls with same script without mod_rewrite – LeonidMew Oct 18 '18 at 0:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.