• Dear friends, I used the following configuration of permalinks:
    /%category%/%postname%/

    Now, I use this setting:
    /%category%/%postname%-%post_id%/

    I want to know is how I have to configure it to redirect all posts automatically to the new structure of permalinks.

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You could do search+replace throughout with the database or manually, and a bunch of 301 redirects.. You’re adding-to, and a hyphen isn’t a standard break in wordpress (like the slashes are), so it can get cumbersome.

    I would consider using .htaccess rewrite to help: I’d configure the new permalink to:

    /%category%/%postname%/%post_id%/

    then, with .HTACCESS do a rewrite that would “change” your permalink structure to what you’d really like it to be..

    You’ll have to look it up on how to rewrite it properly – I’m guessing here, but basically you’re identifying the URL with your custom permalink (with the hyphen), but telling the server it’s actually a backslash (as WordPress expects). so the world see’s the hyphen, but the code sees the backslash:

    RewriteEngine On
    ...
    /(.+?)/(.+?)/(.+?)/ /$1/$2-$3/
    ...

    I suggest this because: WordPress should be able to redirect old /%category%/%postname%/ to the new /%category%/%postname%/%post_id%/ automatically, with no problem, so old links are preserved, and the URL after the redirect can be altered with rewrites to change the backslash to the hyphen to the public.

    Thread Starter umarizal

    (@umarizal)

    Friend, how do I use this setting in .htaccess?

    RewriteEngine On

    /(.+?)/(.+?)/(.+?)/ /$1/$2-$3/

    I′m newbie, please, have patience ??

    sorry – I don’t have that answer – you’ll have to research it: https://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/

    Thread Starter umarizal

    (@umarizal)

    I read but I still can not understand how to do, at least not in this case.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to configure automatic redirect to new structure of permalinks?’ is closed to new replies.