• Resolved thewhitegeek.com

    (@thewhitegeekcom)


    i already have a wordpress website that have many posts and pages – the posts links format is : MYWEBSITE.COM/POST_NAme – the pages link Format is : MYWEBSITE.COM/PAGE_NAME

    now i want to change only the permalinks of POSTs to MYWEBSITE.COM/blog/POST_NAme

    when this is done , the old links of posts ( MYWEBSITE.COM/POST_NAme ) will give 404 error , how can i make a redirection only for posts from MYWEBSITE.COM/POST_NAme to MYWEBSITE.COM/blog/POST_NAme ( without changing pages links )

    thanks

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author John Godley

    (@johnny5)

    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.

    Thread Starter thewhitegeek.com

    (@thewhitegeekcom)

    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

    Plugin Author John Godley

    (@johnny5)

    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/

    Thread Starter thewhitegeek.com

    (@thewhitegeekcom)

    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

    Plugin Author John Godley

    (@johnny5)

    I understand your situation. You should have enough information above to proceed.

    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.

    Plugin Author John Godley

    (@johnny5)

    No, it doesn’t monitor permalink changes. Please see https://redirection.me/support/redirect-regular-expressions/

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘redirect only Posts after changing permalinks’ is closed to new replies.