Problem
I would like to redirect from website.com/PRODUCT/name-of-item to website.com/COURSES/name-of-item. There are too many products to do them individually.
Also, as the term product does appear in the name-of-item part sometimes (eg. product-best-rating), I need to be mindful of that.
Many users have asked similar questions. I have tried the solutions and they do not work for me.
What I tried - Solution 1
Solution 1: Rewrite only the middle part of URL - mod rewrite .htaccess
My code for Solution 1 is this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^product/(.*)$ /courses/$1 [R=302,NE,L]
</IfModule>
# END WordPress
Results: https://website.com/product/normal-product/ still redirects to https://website.com/product/normal-product/
What I tried - Solution 2
Solution 2: https://webmasters.stackexchange.com/questions/102402/how-to-bulk-redirect-urls-and-replace-one-path-segment
For Solution 2, my code would be this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^/?product/(.*)$ https://website.com/courses/$1 [R=301,L]
</IfModule>
# END WordPress
Results: https://website.com/product/normal-product/ still redirects to https://website.com/product/normal-product/
