You can use a regular expression to redirect a lot of URLs:
https://redirection.me/support/redirect-regular-expressions/
You would need to exclude /blog/ from being redirected.
thank you for you reply ,
when i go to settings->permalinks then i change to custom permalink
MYWEBSITE.com/blog/%postname%/
now all the posts published in social media and emails will not work , because their link is MYWEBSITE.com/%postname%/
the SOLUTION is
redirect links by regular expressions from MYWEBSITE.com/XXXXX to MYWEBSITE.com/blog/XXXXX
but the problem now that the pages have the same regex so the page also will be redirected to /blog/pagename and ten i will have 404 error ,
i want that the regexe applied to posts only
Sure, as I said you want to exclude /blog/ from the redirect, either by excluding it in the regular expression, or using a ‘do nothing’ action https://redirection.me/support/redirect-actions/
the redirection will be
MYWEBSITE.com/XXXXX to MYWEBSITE.com/blog/XXXXX
so there no mean to exlude blog .
i wantt tom ake this redirection ny regex
MYWEBSITE.com/XXXXX to MYWEBSITE.com/blog/XXXXX
but only for posts
please read again my situation , thanks
I understand your situation. You should have enough information above to proceed.
CB
(@cbrandt)
Hi @thewhitegeekcom,
but only for posts
You’d need to create one redirect for each one of your posts, since, to the best of my knowledge, there is no way Redirection or any other plugin would differentiate a post from a page based only on a /%postname%/-type source URL. If you have many posts, one workaround you could try is this:
Install a plugin called Yoast SEO or any plugin that can generate sitemaps by post type.
If you install Yoast SEO, and set it to generate sitemaps, your site should have a sitemap at example.com/post-sitemap.xml with a list of all your posts (but none of your pages). Assuming you already implemented the permalink change you mentioned, this sitemap will have URLs like:
/blog/some-post/
/blog/another-post/
You can use an online XML to CSV converter and/or use your Excel copy-and-paste and search-and-replace skills to create a CSV file with these URLs as the target URLs, and just copy them and remove the /blog part to generate the source URLs. You may want to avoid regex for grouping more than one post, as any such regex may end up redirecting similarly titled pages (that you have now or may have in the future.)
You should create a CSV structure following the import instructions here:
https://redirection.me/support/import-export-redirects/.
When you run the importer, make sure you create a new redirect group and import the CSV URLs all to it, so that you can later manipulate them, including deleting them if something goes wrong or you need to re-import after making changes.
If ‘Monitor changes to posts’ is checked, would then changing the permalink structure cause the appropriate redirects for all the posts to be then created automatically?
I am also planning on changing my permalink structure, to remove the month/date from the current structure so only the post name is shown.