Forum Moderators: phranque

Message Too Old, No Replies

Redirect or not?

www.domain.com/.

         

g1smd

6:04 pm on Sep 7, 2008 (gmt 0)

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



I have a site that often has broken incoming links from forums and blogs where URLs are auto-linked.

The incoming links point to URLs in the form of www.domain.com/some.folder/. or www.domain.com/some.file.html.

The site issues a 301 redirect for those to strip the trailing dot from the URL... except that it doesn't work for www.domain.com/. at all.

However, do note that an incoming link to www.domain.com/. is actually listed in Google Webmastertools under links to the root domain.

So, do I really need to bother redirecting for that single case?

A different rule for www.domain.com. and www.domain.com./ does work as expected. Both redirect to www.domain.com/ as expected.

jdMorgan

7:29 pm on Sep 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, the dot before the slash that initiates the URL-path simply specifies a fully-qualified domain name (FQDN), whereas a dot following that slash is seen as a URL-path.

So how/why doesn't the the redirect for "/." work? I'd imagine a simple rule in .htaccess like


RewriteRule ^(([^/]+/)*)\.$ http://www.example.com/$1 [R=301,L]

would suffice to handle that case.

Jim

g1smd

7:49 pm on Sep 7, 2008 (gmt 0)

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



That works, except that requests for www.domain.com/folder. used to redirect to www.domain.com/folder then redirect again to www.domain.com/folder/ but now that request is simply issued with a 404 in reply.

I need to think how to fix this for both instances.

jdMorgan

8:49 pm on Sep 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, generalizing one more step...

RewriteRule ^(([^/]+/)*[^.]*)\.$ http://www.example.com/$1 [R=301,L]

The /folder-to-/folder/ redirect would have to be handled as a special case, because it's really two errors, unless you want to do it with file-exists checks (slow).

RewriteCond %{DOCUMENT_ROOT}/$1 -f
RewriteRule ^(([^/]+/)*[^.]*)\.$ http://www.example.com/$1 [R=301,L]
#
RewriteCond %{DOCUMENT_ROOT}/$1/ -d
RewriteRule ^(([^/]+/)*[^.]*)\./?$ http://www.example.com/$1/ [R=301,L]

Basically, this is one of those cases where *you* have to find the shortest distance between two points in the non-Euclidean geometry of *your* URL-space... :)

Jim

g1smd

8:59 pm on Sep 7, 2008 (gmt 0)

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



I know. I know.

This has been ongoing; I thought I had fixed all cases months ago, but WMT threw up those new cases in the last week or two.

.

However, I do note that an incoming link to www.domain.com/. is actually listed in Google Webmastertools under links to the root domain, i.e. in the same list as links to www.domain.com/ are, so maybe I don't need to fix it.

jdMorgan

9:37 pm on Sep 7, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to fix it -- It's more than one URL for the same content. Don't rely on Google or any other SE to clean up inbound link duplication; They might fail to do it properly or just not have time to do it within a given particular indexing cycle.

A regression bug in such an obscure URL clean-up routine buried deep in a search engine's back-end processing routines might go unnoticed and/or un-fixed for a long time...

Asked why I canonicalize everything, I answer, "Because I can." :)

Jim