Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

htaccess redirect for permalinks

         

Gemini23

6:52 pm on Mar 31, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can anyone advise the correct code to add to htaccess if changing the permalink structure? thanks in advance.
Wordpress installation is in the root not in a folder.

OLD/CURRENT (Custom) PERMALINK (with 'Category base as 'shows')
/news/%post_id%/%postname%/

NEW (Custom) PERMALINK (with no Category base)
/%category%/%postname%/

seoskunk

12:09 am on Apr 12, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I think because each post has the post id and the category has changed as well your going to need to set up individual redirects for each post. I wouldn't use .htaccess I would use a Redirect plugin for wordpress that accepts csv files like this one [en-gb.wordpress.org...]

Here what I would do:
1. download the sitemap of all the urls posts in existing format. Add it to column one of your csv file
2. in column 2 map the new url for each post in the csv file
3. upload - job done

phranque

3:21 am on Apr 12, 2018 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



if you don't want to rely on a plugin for this, you could easily add an internal rewrite so that all requests for the /news/... paths are sent to a script that handles the redirect responses using the same csv file described by seoskunk.