Use a redirection plugin, or add rules to your HTACCESS file to do 301 redirect.
Thanks Mike!
Seems like a easy fix then. What did I do wrong in the first place to cause this duplication?
Am I correct that using HTACCESS rules is preferred over a redirect and a simple re-write is all that is needed? And this needs to go above the WordPress rewrite rules?
RedirectMatch 301 ^/necklaces/(.*)$ http://www.woodyouwear.com/shop/wooden-statement-necklaces/$1
So the HTACCESS would look like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RedirectMatch 301 ^/necklaces/(.*)$ http://www.woodyouwear.com/shop/wooden-statement-necklaces/$1
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I believe WP handles the redirects usually – not sure why you’d have 2 working links. Possibly caching?
htaccess is usually better for performance than a plugin.
Appreciate the help Mike. My above HTACCESS 301 redirect isn’t working so when I do figure it out properly, I’ll add it here for anyone facing the same issue.
For anyone following along, a rewrite rule in HTACCESS worked for me. I had to put the new rewrite rule before the wordpress ones.
‘RewriteRule ^(.*)/necklaces/(.*)$ $1/wooden-statement-necklaces/$2 [L,R=301]`
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(.*)/necklaces/(.*)$ $1/wooden-statement-necklaces/$2 [L,R=301]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
ContestHound –
Just as an aside for anyone else reading, this is probably the “right” way to do it anyway. For example if Google had indexed your “old” category page and it suddenly disappeared it might affect your rankings for that page briefly, until Google indexed your site again and figured out where the “new” category was. This way with the redirect it’s pretty seamless.
What I’d suggest though is going through your own content to make sure you’re not linking to the old URL anywhere just for neatness’ sake. If you’re handy with SQL maybe consider something like this:
https://ww.wp.xz.cn/support/topic/updating-links-in-old-posts-when-things-change?replies=5
(note if you aren’t handy with SQL maybe don’t do that since it’s easy to screw something up)
That deals specifically with links inside the body of posts, so it doesn’t fix everything. Other places to check would be menus, widgets, sliders/blocks, etc.