1
votes

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

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?

1
category is a dynamic or static value ?Justin Iurman
It is dynamic through Wordpresshousamz
Do you have other urls like /foo/bar (with 2 arguments, one subdirectory) that have nothing to do with categories and post name ?Justin Iurman
No, it is only one category and then the post namehousamz

1 Answers

2
votes

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