Reputation: 5839
I have changed the url structure on a wordpress site and need to 301 the old urls to the new ones. The old structure was as follows:
/news/[category-name]/[post-url-slug]
So it was always /news then it would have the url slug for the category and then the url slug for the post name.
The new structure is as follows:
/[post-url-slug]
So I have basically got rid of the news and category name portion of the url. How would I 301 all the old urls to the new ones in my htaccess? mod rewrite is enabled.
Upvotes: 0
Views: 145
Reputation: 678
Add this to your .htaccess or apache config:
RewriteRule ^news/.+?/(.+)$ $1 [R=301,L]
You might want to be more specific than .+
depending on the rules for your category and post names. Eg: [a-zA-Z0-9-_]+
or similar.
Have a play on debuggex if needed:
Upvotes: 1