Forum Moderators: phranque
GENERATED (INCORRECT) URL EXAMPLES:
h*tp://www.example.com/alphanumeric-string/comment-page-1#comment-4357
h*tp://www.example.com/alphanumeric-string/comment-page-2#comment-4357
h*tp://www.example.com/alphanumeric-string/comment-page-3#comment-4357
CORRECT URL EXAMPLE:
h*tp://www.example.com/alphanumeric-string#comment-4357
GENERATED (INCORRECT) URL EXAMPLES:
h*tp://www.example.com/alphanumeric-string/comment-page-1
h*tp://www.example.com/alphanumeric-string/comment-page-2
h*tp://www.example.com/alphanumeric-string/comment-page-3
CORRECT URL EXAMPLE:
h*tp://www.example.com/alphanumeric-string
So I think I need my .htaccess to strip out "/comment-page-[any number]".
My logic is:
h*tp://www.example.com/[anything] /comment-page-[any number] [anything]
... to become:
h*tp://www.example.com/[anything][anything]
My proposed rule is:
RewriteRule ^(.*)(/comment-page-)([0-9])(.*)$ /$1/$4 [R=301,L]
Is my logic correct, and do I need a RewriteCond before the RewriteRule?
Patrick
RewriteRule ^([0-9A-Za-z]+)/comment-page-[0-9]+(.*)$ http://www.example.com/$1/$2 [R=301,L]
There are a couple of tutorials about what mod_rewrite can and can't do for you in our Apache Forum Library here at WebmasterWorld if you'd like to read more details.
Jim
[edited by: jdMorgan at 4:25 pm (utc) on Aug. 24, 2009]
Point taken regarding fixing the source of the problem. In this instance there's not much I can do about it without editing a WordPress core file, which will be over-written with each upgrade. Fortunately I have very few 'problem' links and those I do have appeared only yesterday.
And yes, over the years I've received a lot of assistance with .htaccess both from you and from the Apache Forum Library. The trouble is, I dip into mod_rewrite only every now and then, and my understanding of what I've done fades with time.
Many thanks again.
Patrick