How can I redirect all WordPress post URLs that don't contain a subcategory to prevent duplicate content?

How can I redirect all WordPress post URLs that don't contain a subcategory to prevent duplicate content? - If a page has internal and external outgoing links to redirecting URLs, it’s returning 3xx (301, 302, etc.) HTTP status codes standing for redirection. This issue means that the page does not exist on a permanent or temporary basis. It appears on most of the popular web browsers, usually caused by a misconfigured website. However, there are some steps you can take to ensure the issue isn’t on your side. You can find more details about redirecting URLs by reading the Google Search Central overview. In this article, we’ll go over how you can fix the How can I redirect all WordPress post URLs that don't contain a subcategory to prevent duplicate content? error on your web browser. Problem :


On my WordPress site, I have this URL format:



/%category%/%postname%/


When I create a new post and select a parent category and a sub-category and select sub-category to default then WordPress builds a URL that looks like this:



/parent-category/sub-category/postname1


This URL and the top URL:



/parent-category/postname1


are both working correctly and both show that one post.



The problem starts when Google says one of them is a duplicate post.



Now I want to redirect this URL



/parent-category/postname1


to this url



/parent-category/sub-category/postname1


for all posts on the entire site and for future posts.


Solution :

Personal Feeling about Categories in Paths



Personally, I stopped going crazy about categories and actually even removed them completely from my websites. They not only don't help because people don't search those lists (my hits on those lists has always been dismal) but as you can see it creates duplicates. So I deleted all my categories.



As a result my URLs are just:



/%postname%/


And everything works like a charm.



If you expect a really large number of posts (thousands) on your website, though, having top-level categories may still be a good idea. For small sites, it's just a big waste in all sorts of ways.



Oh and as a result of removing the categories on my websites, it looks like I gained in rank since I get more traction. Not a lot more, but I still noticed.



Redirect—to answer your question



I don't know of a plugin to redirect from sub-paths to the main path. Such may exist. Of course, there are plugins you could use to create redirects by hand, but that would be really tedious.



Note that a large number of 301 is not ideal for a website. You'll notice that Google Console reports those as errors (although the new console version does not mark them as errors but warnings. So it may be fine as long as you add a single such 301.)



Canonicalization



Another way for Google is to fix the canonicalization of the page. So instead of a redirect, you create a canonical meta tag which includes the path you want, whatever the sub-categories. I'm not too sure how you control that under WordPress. I would suggest you test the various plugins that say they can create/fix your canonical path.



To verify the canonical, look at the resulting page source and make sure that the header meta tag looks correct. It has to be a full URL (i.e. including the protocol, domain name, and path.)



Note that Google still gives you a warning about such pages, saying that it found page blah with canonical foo. This is fine, though.


We hope that this article has helped you resolve the seo, redirects, wordpress error in your web browsers. Enjoy browsing the internet uninterrupted!

Comments

Popular posts from this blog

How to redirect to any domain [duplicate]

"302 found" for index page bad for SEO?

Create redirect from url like www.example.us/?p=100&option=