SEO: do we need to redirect also pages with final slash?
Anytime there is a difference in any part of the URL, even if it is capitalization or parameter order, search engines will view it as a unique URL.
A) Yes, they are still different URLs, even if it's the domain. You might find the following code useful for your .htaccess file:
#change RewriteBase to / after transfer
RewriteBase /
#Redirects non-www to www
RewriteCond %{HTTP_HOST} ^domain.com
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]
B) These are considered different URLs, but you shouldn't be using a trailing slash directly after a file extension even if the browser still interprets it correctly. I don't think I have ever seen a slash directly after a file extension, so I wouldn't worry about it too much unless you yourself are linking to your pages that way. Don't use the slash after the extension.
In general, stay consistent with your URL schemes. Pick one way and stick with it.
Trailing slashes on the domain name are treated exactly the same as no trailing slash, i.e. http://www.domain.com
= http://www.domain.com/
.
But that's the only exception. Any other time the URL differs, it can return completely different content and thus is treated as a different URL.
Any file returned (with an extension like .htm
or .php
) should not have a trailing slash. You will find on the Apache server that trailing slashes are usually ignored and the file is returned. This is just how Apache works; the URL example.com/file.php/abc/xyz
will go back to file.php
, assuming there is no actual file or folder structure like the above.
Directories generally have trailing slashes - again, Apache will automatically 301 redirect to them. For example if you have a folder hello
then example.com/hello
should redirect to example.com/hello/
.