skip to Main Content

To change the permalink of my site from /%postname%/ to /%postname%-1/, I need a 301 redirect code and I don’t want to use a plugin.
What code should I use?

2

Answers


  1. Set up the 301 redirects from the old URL permalink structure to the new one in WordPress.
    Add this code to your .htaccess file.

    RewriteEngine On
    RewriteRule ^(.*)$ /$1-1 [L,R=301]
    

    Note: make sure to take a backup of your .htaccess file before do any changes.

    Login or Signup to reply.
  2. Make a complete backup of your .htaccess file before changing anything. Try this:

    1. Log in to your WordPress dashboard and navigate to Settings > Permalinks.
    2. Select the "Custom Structure" option and enter /%postname%-1/ in the field.
    3. Save changes to update your permalink structure.

    Then add this to your .htaccess

    RewriteEngine On
    RewriteBase /
    RewriteRule ^(.*)/?$ /$1-1/ [R=301,L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search