Page is a not externally linkable
- Google
-- Google SEO News and Discussion
---- Why am I seeing duplicate content with session id?


jdMorgan - 5:34 pm on Nov 30, 2008 (gmt 0)


Coming late to this party, the following changes would seem to be warranted:

# Redirect requests for index.html in any directory to "/" in the same directory
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /(.+/)?index\.htm[b]l(\?[^\ ]*)?\ H[/b]TTP/
RewriteRule ^(.+/)?index\.html$ http://www.example.com/$1? [R=301,L]
#
RewriteCond %{QUERY_STRING} .
RewriteRule (.*) http://www.example.com/$1? [R=301,L]
#
# Redirect requests for resources in non-www domains to same resources in www domain
RewriteCond %{HTTP_HOST} .
RewriteCond %{HTTP_HOST} !^www\.example\.c[b]om$[/b]
RewriteRule (.*) http://www.example.com/$1? [R=301,L]

Changes:

  • Modified RewriteCond pattern in first rule to match whether or not a query string is appended.
  • Modified second RewriteCond in last rule (non-www to www redirect) to remove the [NC] flag and end-anchor the pattern. The result is that the redirect will occur unless the hostname is *exactly* "www.example.com" or, in the case of HTTP/1.0 requests, blank.

    Note that that whole rule can be coded more efficiently in only two lines as:

    # Redirect requests for resources in non-www domains to same resources in www domain
    RewriteCond %{HTTP_HOST} ![b]^(w[/b]ww\.example\.co[b]m)?[/b]$
    RewriteRule (.*) http://www.example.com/$1? [R=301,L]

    Jim


    Thread source:: http://www.webmasterworld.com/google/3793076.htm
    Brought to you by WebmasterWorld: http://www.webmasterworld.com