: How to re-direct Wordpress posts with 301 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
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:
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/
More posts by @Marchetta884
3 Comments
Sorted by latest first Latest Oldest Best
I advise you to add your redirects via your control panel redirection section ( each control panel has this section for all types of domains) or just use .htaccess configurator via the link enter link description here
If the urls always have a "real" folder depth of 2, this should work. It's basically saying "find pattern of any one or more characters that are NOT slash followed by slash, repeated twice". (.*) matches any chars that come after the 2nd slash (the random crap you want to throw away)
RewriteRule ^([^/]+/){2}(.*)$ www.example.com/ [R=301,NC,L]
First, I'd look at your URL settings (under "permalinks") to see why these URLs are being produced in the first place. I don't think they are by default. Ideally, you can just stop this from happening.
Second, is your site offering links to these unwanted duplicates? If so, I'd advise preventing that. If they're not linked to, users and search engines should never arrive at one.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.