How to fix 404 issues after removing category - wordpress

This is actually an SEO question. I do know quite a bit of SEO but in this case, it's to do with 404's being created across my website. Essentially the WordPress site has left a string of pages not found. The initial installation used the "category" prefix, and now as that has been removed, I have tonnes of 404's popping up. What is the best way to deal with these as there is pagination for each category and there may be hundreds of errors? Making individual 301's does not seem like the best option. And I do not think using regex will work as that redirects to the root address, right? Thanks, everyone for your time.

Just set redirect 301 from your category slug to another page
if your category slug is news, so set a regular expression for all posts that they were in this category and redirect this pattern to another page or post or ....
Just do it in Yoast SEO
from: yoursite/news/[a-zA-z0-9]
to: yoursite/anotherPage

Related

Is it possible to automatically add a slug to an already existing URL once permalink structure has been changed?

I am running a website in which the different posts all have an associated category: let's say, news, reviews, videos, etc.. We want to change how URLs are generated to incorporate the category before postname.
I will put an example:
old url: https:///www.myweb.com/amazing-new-car (with category in the post being news)
new url: https:///www.myweb.com/news/amazing-new-car (with category in the post being news)
I know how to do this by changing permalink structure in the wordpress settings to /%category%/%postname%/ but the problem is that this is applied to older entries too so when i try to access https:///www.myweb.com/amazing-new-car it gives me a 404 error. The problem here is that we have links to parts of our site sent to people, social networks and so and if they use them they will see this 404 error.
I've tried to use Redirection plugin to create a rule that can redirect old URLs to new URLs but it does not work (i've tried even wildcard redirection).
My question is: is there any way to do what i want rather than individual renaming of the links?
Thanks in advance, i hope i've explained well my problem
WordPress has all the tools necessary to make this change happen, and typically it does successfully redirect the slug from /slug to /news/slug
If you have added a category and haven't touched permalink settings, this is probably your problem.
Once you add a new category or post type into Wordpress, you should go into the Permalink settings and just click save. No need to change the settings if you are happy with them...

How to replace /category and /tag with /blog while adding /blog to posts in a WordPress URL without plugins

I would like to adjust the permalinks of my wordpress site without using a plugin. I want to get rid of "/category" and "/tag" while adding a prefix "/blog" to all blog related sites (category and tag overview plus posts).
I use several categories including sub-categories as well as tags but no custom post types. For example:
Category "animals" with sub-categories "dogs", "cats" and a tag "pet-food"
One post per sub-categorie, each tagged with "pet-food"
Hosted on www.example.com
For pages I don't need any customization resulting in www.example.com (/page-A).
For posts the following structure would be ideal:
(1) www.example.com/blog; Showing all three posts
(2) www.example.com/blog/animals; Showing all three posts
(3) www.example.com/blog/animals/dogs; Showing the one post about dogs
(4) www.example.com/blog/animals/dogs/post-about-dogs; Reading the post about dogs
(5) www.example.com/blog/pet-food/; Showing all three posts
I tried so far several approaches. First of all I went to settings -> permalinks and chose the custom permalink option adding
/blog/%category%/%postname%/
while leaving the category and tag base options untouched. Here everything is working besides that "/category" and "/tag" still show up in cases 2,3 and 5.
By adding a "." into the optional category base the "/category" disappears in case 2 but now the url of case 3 (with and without "/category") isn't working. Case 5 is still unfixed.
By adding "/blog" instead of "." case 2 and 3 will work both without "/category" as intended but now cases 4 and 5 are broken.
I tried several other combinations with also changing the tag base and in none approach every link variation worked. I even tried a couple of times to reset the htaccess file in between different settings with no success.
I already considered Remove category & tag base from WordPress url - without a plugin and dozens of other sites. But unfortunately no configuration worked for me so far. I even tried to strip of the "/category" with the option provided by Yoast SEO (which is already installed and what can be used if needed) but this resulted into also cutting of "/blog".
Any help is much appreciated - it would be great if you have a solution for this problem!
I finally found a solution to this by myself.
Go to Dashboard -> Settings -> Permalinks and use the custom permalink structure "/%category%/%postname%/"
Change the tag base to "blog" leaving the category base untouched
As I said I already had Yoast SEO so I used it to strip the word "category" for category overviews away (Yoast SEO -> Advanced [maybe you have to enable advanced options first] -> permalinks -> choose remove /category
As I wanted "/blog" as base for all blog related posts I added the category "blog" as parent to all existing top categories
Enjoy!
Issues why this procedure is needed:
/blog/%category%/%postname%/ as permalink structure is not working in combination with removing /category - at least if you are using a plugin for that (I tried several). I know that I wanted an approach without plugin but I found no code solution and I used Yoast anyways.
You cas set your posts to "/blog/%category%/%postname%/". If you now change the category base to "." you don't have to eliminate the /category anymore. But this resulted into 404 errors while changing the base to "/blog" results into a wrong url structure.
Issues with this approach:
Your archives ordered by date will be reachable by example.com/year/ instead of example.com/blog/year
Simple, install YOAST plugin:
http://prntscr.com/mpcge6

Achieving flat URL structure with woocommerce for SEO

In an attempt to make a multilingual woocommerce website with a flat url structure we thing would be best for our store's seo, we tried every combinaison plugins/features/sustom code/htaccess we know and could not make it happen.
I know WP suggests NOT to remove the base slugs from urls but the main reason is to avoid conflict between slugs and we intend on writing ALL slugs manually.
So, in short lets says we have categoryA and categoryAB (child of A) and a productnamedsomething associated to categoryAB.The usual URL of woocommerce would be:
www.domain.com/product-category/categoryA/categoryAB/productnamedsomething
while we would simply want:
www.domain.com/productnamedsomething
up to there, the WP htaccess Control plugin was working wonderfull, but adding multilangual fonctionnality made it complicated.
We tried both polylang and WPML and could not achieve in any way our target URLs:
www.domain.com/productnamedsomething
www.domain.com/fr/unproduitquelconque
However, typing any of these URL in the address bar works and displays the product, without the category tree. But we cannot get menus, category menus and other links to point to a flat url structure.
So the main points here are:
Did anyone succeed in creating flat url structure in woocommerce and what was the wining combinaison of plugins/hack used?
If not, what would be the best way to go about it, manually removing categories using htacess or maybe overwriting theme functions to change widgets and menu links structure in php?
Is all this worth the hassle or is woocommerce's basic url structure
better than it feels for a shop's SEO?
Ask clarifications if needed, i'll be glad to discuss this.
Have you tried the WordPress rewrite API? https://codex.wordpress.org/Rewrite_API

Woocommerce - Removing manually part of the URL cause 404 error

As mentioned in the Google's "Search Engine Optimization Starter Guide" (pg 11) a good SEO practice is to give the possibility to users to remove manually part of the URL in the address bar.
In my case:
mysite.com/shop/mycategory/myproduct <-- product page with category ok
removing now manually part of the URL above:
mysite.com/shop/mycategory/ <-- error 404
mysite.com/shop/ <-- works
Breadcrumb in the product page look like this:
home / shop / mycategory / myproduct
clicking on mycategory links to:
mysite.com/product-category/mycategory <-- works
The problem is that the two URL differs:
mysite.com/product-category/mycategory
mysite.com/shop/mycategory/
Any clue on how to resolve this?
From looking at the documentation and other similar posts, some permalinks are not recommended to be adjusted for performance reasons. Your
"mysite.com/shop/mycategory/myproduct"
url is actually looking at:
"mysite.com/shop/product-category/mycategory/myproduct"
So it doesn't look like you will be able to shorten it in the way you describe, although you could restore the "product-category" permalink that i assume you have removed? this way the user will be able to shorten the URL without hitting a 404 error.
http://docs.woothemes.com/document/permalinks/
WooCommerce- How to remove product & product-category from urls?

Wordpress and Woocommerce: remove /product and /product-category from URL structure

Dear StackOverflow friends,
in a site with Wordpress and Woocommerce plugin,
I would like to change the URL of the pages of e-commerce in an SEO friendly structure and in particular I would like:
1) the individual product pages
www.mysite.com/product/productname
to become
www.mysite.com/productname
2) and the product category pages
www.mysite.com/product-category/categoryname
to become
www.mysite.com/categoryname
As regards the case 1 /product,
I have not found a plugin that could help me and I tried
A- to modify WordPress permalinks: inserting a slash followed by a dot /. products , URL takes on the structure that I want but the pages are no longer accessible and bring me an error of 'redirection loop'
B- to modify the .htaccess file, adding the following lines of code
// 301 Redirect Entire Directory
RedirectMatch http://testmywpshop.info/prodotto(.* 301) http://testmywpshop.info/$1
but probably I have not written/inserted that code correctly, because the site becomes inaccessible!
As regards the case 2 about /product-category,
I tried the plugin SEO Ultimate which has the function that suites my needs and I successfully converts the URL structure of product categories, but I'd prefer to get the same result without using it, because my friend wants to use SEO Yoast and there may be conflicts between these two plugins.
In conclusion, I wish URL wouldn't suffer broken links and redirections to be more acceptable to Google (maybe using the 301 redirection because it seems to be the only liked by robots) or even change the WordPress core code that determines the structure of the URL, but I have not been able to find it!
I read this Stack post and this Woocommerce documentation but I'd like to find an alternate way, if possible in your opinion.
I would also be happy to know your opinion about the usefulness of a modified URL structure, removing irrelevant words to the products sold in a e-commerce, to meet Google requirements (I found conflicting information about this subject).
Thanks for your advice and your help!
I would also be happy to know your opinion about the usefulness of a modified URL structure, removing irrelevant words to the products sold in a e-commerce, to meet Google requirements (I found conflicting information about this subject).
If you are looking to do this change to meet SEO Best Practices requirements, please note that this particular URL suggestion happened due to products that belong to multiple categories.
As such, urls that include categories can be detrimental.
www.example.com/product/drinks/milkshake and www.example.com/product/desserts/milkshake point to the same product. However, the problem here is not /product/ but /drinks/ and /milkshake/.
a WooCommerce site with a default product url like www.example.com/product/product-name is technically ok. I prefer to set my urls to www.example.com/shop/product-name as well as www.example.com/shop/category-main/category-sub/ as it is more descriptive. You can do this on WordPress Admin>Settings>Permalinks.
That said, if WooCommerce documentation says it's not a good idea, I usually don't pursue it. :)
Its possible to change the url structure, use a plugin for this.
old situation: domain.com/product/blue-trouser
new situation: domain.com/blue-trouser
or with categories
old: domain.com/product-category/pants/blue-trouser
new: domain.com/pants/blue-trouser
You will have to buy a plugin to get it this way.

Resources