-
I have changed the permalink structure from /%postname%/ to /blog/%postname%/ how do I create a redirect that affects all blog articles?
-
Hello,
I apologize for the issue you are facing with changing the permalink structure and creating redirects for all blog articles. To create a redirect that affects all blog articles after changing the permalink structure, you can use Rank Math’s Redirection Manager feature.
Here’s how you can set up a redirect for all blog articles:
- Navigate to your WordPress Dashboard.
- Go to Rank Math SEO and then click on Redirections.
- Click on the Add New button to create a new redirection.
- In the redirection settings, enter the old URL structure (e.g., /%postname%/) in the Source URL field.
- Enter the new URL structure (e.g., /blog/%postname%/) in the Destination URL field.
- Save the redirection.
By setting up this redirect, all your blog articles’ URLs will automatically redirect from the old structure to the new one (/blog/%postname%/). This will ensure that your visitors are seamlessly redirected to the correct URLs without encountering any broken links.
If you need further assistance or encounter any issues while setting up the redirect, feel free to reach out to our dedicated support team by clicking here.
Thank you for raising this concern, and we appreciate your understanding as we work to resolve this for you.
Closing spiel:
If you have any more questions or need further assistance, please don’t hesitate to ask. We’re here to help!Sources:
WordPress Permalink Structure & Changing Individual URLs Ā» Rank Math
How to Remove a Specific Word From Your Permalinks (URLs) Ā» Rank Math
Analyzing Your Site’s SEO with Rank Math’s SEO Analysis ToolTo ensure seamless redirection for all blog articles after changing the permalink structure, access your website’s .htaccess file. Insert the following code snippet above the WordPress generated rules:`RewriteEngine On
RewriteRule ^(.*)$ /blog/$1 [R=301,L]
`
This code redirects any URL structure to include ‘/blog/’ before the original post name. For instance, ‘example.com/old-post’ becomes ‘example.com/blog/old-post’. The ‘R=301’ indicates a permanent redirect, beneficial for SEO. Ensure to save the .htaccess file and test the redirection to confirm its effectiveness. This approach guarantees a smooth transition without affecting your site’s SEO or user experience.I know this because recently I found a friend’s website called Winchinsider. This was Parmaling’s issue in it. He also wanted to cut short from it and wanted to describe it beautifully. So he designed his website page something like this using the same method.Hello,
Thank you for your query, and we are so sorry about the trouble this must have caused.
You can get this done using this short hook/filter code :
Hereās how you can add filter/hook to your WordPress site:
https://rankmath.com/kb/wordpress-hooks-actions-filters/We hope that helps, and please don’t hesitate to get in touch if you have any other questions.
Thank you.
Hello Alhan
I like the snippet but my website has multiple post types for services etc, not every time someone lands on the 404 page I want them redirected this should only run for posts
Thank you
Hello,
The old permalink structure for your posts has the same format as your regular pages (or even other CPTs) so you can’t simply achieve that with our redirection module via regex. You’ll have to do manual redirections instead.
If you do it programmatically, old permalink structures are now throwing 404s, and it’s impossible to determine if that URL is from a post type.
Your option here is to make redirections manually for each old URL or apply the filter code my colleague suggested.
Hope that helps and please do not hesitate to let us know if you need our assistance with anything else.
Hello,
Glad you were able to get it to work.
You could also ditch the extra check for 404s and just redirect every
/post-name/
of thepost
post type to /blog/post-name.Something like this: https://i.rankmath.com/n/MHIhHl
In any case, we’re happy this issue has been resolved. If you need help with anything else – please do let us know.
Thank you for choosing Rank Math
Okay,
Please add this feature to the plugin, other redirect plugins have this,
Thanks.
Hello,
Thank you for the suggestion, we sincerely appreciate the feedback and will consider it. In the meantime, if you need help with anything else, please do let us know.
Thank you for choosing Rank Math
Hello,
Nothing else for now.
Kudos!
Hello,
We are glad to hear that this issue has been resolved. Thank you for letting us know. This ticket will be closed now, but you can always open a new one if you have any other questions or concerns. We are here to help you with anything related to Rank Math.
We appreciate your patience and cooperation throughout this process.
Thank you for choosing Rank Math.
The ticket ‘Permalink structure Redirect’ is closed to new replies.