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?
1 Answer
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.
-
2It'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. Oct 16, 2018 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 Oct 18, 2018 at 0:52
http://example.com
vshttp://example.com/
) is different than for a directory (/folder
vs/folder/
).http://example.com
you will see that your browser sends in fact aGET /
request, so at least a/
is mandatory to say "root".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