Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

i read on Google SEO REPORT CARD that for search engines this page:

http://www.domain.com/somepath

is a different page than this one:

http://www.domain.com/somepath/ (note the final slash '/')

Well if this is true i have few questions:


A) Is this true also for home page path i.e. http://www.domain.com.

I mean I already redirect 301 http://domain.com to http://www.domain.com, but how do I redirect also http://www.domain.com to http://www.domain.com/ (with final slash) ??? Actually Apache server or my browser client (don't know who is doing this) seem to already do this sort of redirect becasue if I insert http://www.domain.com in browser bar it always auto adds the final slash making it http://www.domain.com/

So I'm confused, do I need to do anything?


B) Since I still use file extensions, I was not so concerned about redirecting domain.com/somepath to domain.com/somepath/ because all pages in my sites are in the form of somepath/page.htm.

But I noticed anyway a strange thing that is confusing me. If I enter as URL somepath/page.htm the server returns the same page of somepath/page.htm/ (with final slash) instead of an error. I think it's normal because if you look for http://www.php.net/docs.php it returns the same page of http://www.php.net/docs.php/ (final slash), but are these then considered TWO different pages for search engines???

Do I have then to adjust again .htacess in order to redirect 301 each URL with final slash to the same url without the final slash???


Thanks!

share|improve this question
    
Canonical URLs help to avoid this confusion –  John Conde Nov 4 '10 at 1:42
    
@John: That is true but it's best to use 301 redirects where possible. Canonical is just a plaster, it doesn't solve the real problem. –  DisgruntledGoat Nov 4 '10 at 13:51
    
The correct way to write the domain address is with trailing slash. Just for the record. –  DanMan Feb 23 '13 at 19:36
add comment

6 Answers 6

up vote 3 down vote accepted

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/.

share|improve this answer
    
Right! I also found this suggested directly by Google that says it's NOT necessary to "add a missing trailing slash to end of domain name or folder name" sine this "will not be needed by most websites" because Apache server already does this. groups.google.com/group/only-validation/web/… –  Marco Demaio Nov 6 '10 at 17:32
add comment

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.

share|improve this answer
add comment

According to Google SEO Guide, and also common sense, website paths resembles to a directory structure.

So, trailing slash denotes some folder root. Power users will also attempt to do the following:

  • user enters through http://domain.com/articles/2009/nice-shoes.htm
  • user will delete last piece to get into a directory listing, like http://domain.com/articles/2009/, hoping to see all articles from 2009.

Adjusting your URLs according to this, will let an hierarchy more clear to crawl and index.

You can make this correction with .htaccess mod_rewrite for both, add or remove trailing slash, according to your needs. Check:

http://www.google.com/search?q=htaccess+removing+trailing+slash

http://www.google.com/search?q=htaccess+adding+trailing+slash

Hope this helps.

share|improve this answer
    
It would be good to see why I got vote down. Nothing against being vote down when answers doesn't fit, but getting to know why helps everybody, including myself. –  Dave Nov 4 '10 at 12:39
1  
+1 For a helpful, technically-accurate answer and strong agreement on the point that downvotes w/o comment are really worse than useless –  danlefree Nov 4 '10 at 12:57
    
very interesting links. –  Marco Demaio Nov 6 '10 at 17:34
add comment

You can also use the rel=canonical tag to suggest to google the proper URL for their index.

share|improve this answer
add comment

Redirecting to remove the slash is in my opinion the best option, when people link to your site they do it one of two ways, they type out the URL manually in which case they are unlikely to include the trailing slash or they copy and paste in which case the trailing slash would be included, so if you leave the trailing slash up you're likely splitting your links between two URLs (It seems like Google would be sophisticated enough to recognize the two pages are the same, but it's an easy fix so better to be safe then sorry).

If you can't get access to your .htaccess file or redirect these another way then you can use the canonical tag, but it should really be a last resort as it's always better to get your code right then it is to cover it with band-aids.

share|improve this answer
add comment

URLs without the slash are treated as different to URLs with the slash, so in SEO terms, whatever you do, be consistent.

Should you have a slash or not? Of course you should, particularly when dealing with sub-folders.

When requesting http://example.com/foo, the server will first have to look for a resource call foo; when it doesn't find it, it will usually then look for a directory called foo, and if it finds it, it will return the default document.

When requesting http://example.com/foo/, the server knows straight away that foo is a directory, and therefore zeroes in on the default document for that folder.

It's a minor efficiency, but every little helps, IMHO.

See:

share|improve this answer
    
I think it depents on which Web server you use, and your particular application, whether or not the trailing slash helps in the manner you describe. In my case, with the Scala / Lift-Web application I'm building, the trailing slash does not matter at all, w.r.t. performance: I store the documents in a database not in the filesystem. –  KajMagnus Aug 29 '11 at 18:21
    
Yeah, this doesn't really affect performance, but you should know what's the difference. With slash -> folder, without -> file. –  DanMan Feb 23 '13 at 19:40
    
@DanMan Doesn't affect performance? I would have thought the extra 301 redirect would affect performance. From an SEO perspective, it doesn't matter much (Search engines are good at figuring it all out) - providing you are consistent - but from a performance perspective, there is a difference, albeit very minor. –  CJM Feb 24 '13 at 11:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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