I have a wordpress blog with the following URL structure:
www.mysite.com/2016/09/the-name-of-the-post/
However i noticed that for SEO Reasons it would be better to have a structure like:
www.mysite.com/blog/the-name-of-the-post/
I have around 1000 posts with the “old” url structure. I can change the url structure in wordpress. However i would need a 301 redirect if someone tries to access a post using the old url.
E.g.
person/ google bot tries to access page via /2016/09/the-name
-> 301 Redirect to /blog/the-name
What is the best practice to do so? Do I add 1000 lines to the .htaccess file and do redirects? Would that negatively influence the server response time cause apache has to check through a long list of redirects first?
Can I tweak a file in the wordpress file structe which checks, if the requested page is included in e.g. an array, it will redirect it to the new url?
Thank you very much for your suggestions
4
Answers
You can simply change the URL structure in WordPress to the one you want to have. You don’t have to modify your .htaccess or anything else.
WordPress will understand which post is referenced by the URL and redirect to the new canonical URL automatically.
Just go to the Permalinks admin page and select the “Post name” option as described in the Codex.
However, if you’re introducing a prefix like
/blog/
, too, you must redirect to the new URL base through .htaccess, e.g.You can use the following Redirect
This will redirect all urls from this form /1234/12/foobar to this /blog/foobar
Change the permalink to the new structure and add this in your .htaccess
I had the same problem before but I resolve this issue using simple 301 redirects plugin.
https://wordpress.org/plugins/simple-301-redirects/
You can bulk upload 301 redirects using bulk upload add-ons of this plugin.
Hope this will help you.