Mobile app version of vmapp.org
Login or Join
Marchetta884

: 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

@Marchetta884

Posted in: #301Redirect #DuplicateContent #Htaccess #Redirects #Wordpress

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/

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Marchetta884

3 Comments

Sorted by latest first Latest Oldest Best

 

@Cofer257

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

10% popularity Vote Up Vote Down


 

@Si4351233

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]

10% popularity Vote Up Vote Down


 

@Cooney921

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme