Forum Moderators: phranque

Message Too Old, No Replies

htaccess for www and trailing slash

htaccess

         

luvdavy

5:43 am on Mar 9, 2010 (gmt 0)

10+ Year Member



I know you all are tired of these same htaccess questions. I'm so frustrated now.

One of my client's sites is now showing in Google Webmaster Tools as having the domain indexed both with the trailing slash and without. I never include a trailing slash with my links, and never thought it mattered...but I saw Matt Cutts mentioned it the other day. Sure enough, it's now a problem.

I already had a simple htaccess to make the site redirect without the www to USE the www, and it's worked fine. I've looked at all kinds of things about the trailing slash and nothing seems to work with the other.

Can you give me a simple snippet to cover sending the site TO the www version and also to NOT use the trailing slash?

I saw something about it screwing up directories...so if you feel I need to include the slash instead, I'll go with whatever advice you can give. However, I've got to fix it so my links are all in one.

Thanks as always for your wonderful technical help!

Jan

g1smd

9:25 am on Mar 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Do you mean
example.com
and
example.com/
or are you talking about
example.com/something
and
example.com/something/
here?

In this case the HTTP specs rule.

example.com/folder/
- is the URL for a folder, specifically the index page within a folder.

example.com/page
- is the URL for a page of content, using an 'extensionless' URL.

So, which format you use depends on what the URL signifies.



Apache will redirect to add the trailing slash for any folder requests that omit it.

It's a good idea to add another redirect such that requests for pages with an appended trailing slash are redirected to remove that trailing slash.

The exact meaning of the words 'folder' and 'page' are precise in the paragraphs above.

luvdavy

10:23 am on Mar 9, 2010 (gmt 0)

10+ Year Member



I'm talking about the base domain name. Google is showing some of my links directed to www.mysite.com and others going to www.mysite.com/

Matt mentioned this on a video about a week or so ago.
He said the slash/no slash could create duplicate content.

Could this be taken care of by a Canonical mention in the metatags maybe? If so, how?

Thanks for coming to my rescue!

g1smd

11:41 am on Mar 9, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



For domain name only, that is odd, but I wouldn't worry about it all that much. I have not seen that effect in Google listings before. It must be a recent change. In any case, for the URL 'example.com' the browser should know to request 'GET /' any way.

I do always link with trailing slash included though.

For folders it is a vital difference and one that should be fixed.