All my WordPress post URLs generate sub directories with duplicate content and I do not know what regular expression to use to consistently 301 redirect domain.com/category/post/random-number/
to domain.com/category/post/
and domain.com/category/post/random-number/another-random-number/
also to domain.com/category/post/
.
Here is an example of my problem:
http://www.example.com/features/harb-constitution-not-to-allow-kr-provinces-to-receive-foreign-officials/
http://www.example.com/features/harb-constitution-not-to-allow-kr-provinces-to-receive-foreign-officials/1345257927000/
rel="canonical"
: support.google.com/webmasters/bin/… ; googlewebmastercentral.blogspot.co.uk/2009/02/… ; Redirect solution may also work (just generic regex), but since it will be generic regex, it may have false positives. The best solution therefore would be to redirect not at .htaccess level, but rather in actual PHP code, when proper URL is known for sure (compare actual URL to the expected one and if they differ redirect -- exactly the same approach used on this site).