htaccess Redirection for mass links on WordPress site

I had to change my WordPress installation to accept bi-lingual content.
The old URL I was using for posts, where the blog was used only in Italian is:
www.example.com/category/post-name

and the new URL:
English:
www.example.com/post-name

Read More

Italian:
it.example.com/post-name

I am redirecting each URL as follow:
Redirect 301 /category/post-name it.example.com/post-name

Is there any solution to redirect all links from old form to new form, without the need to redirect each link separately?

Related posts

Leave a Reply

1 comment

  1. Taking your comment into consideration, you can put this code in your htaccess (which has to be in root folder) after RewriteEngine On (or RewriteBase, if present) directive

    RewriteCond %{HTTP_HOST} ^www. [NC]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^[^/]+/([^/]+)$ http://it.example.com/$1 [R=301,L]
    

    But it would be better to do it with a WordPress plugin to detect if it’s a category (with post name) url (more reliable).

    Or you can still use a rule for each url but this is painful