Reputation: 115
I previously had a blog in two languages. I installed a multilanguage plugin for that purpose. I regretted doing this and now I bought another domain for one specific language, and want to redirect all the posts and pages of this language to the new domain.
In other words, if someone types mydomain.com/pl/
or mydomain.com/pl/post/
redirect him to mydomain.pl
or mydomain.pl/post/
Is it possible to apply an universal rule that if I redirect mydomain.com/pl/
to mydomain.pl
every other related urls will be redirected as well, instead of doing it one by one? How to do that?
I've tried this that I've seen in another forum but with no luck. Truth is I'm a bit confused with this.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain\.com\pl$ [NC]
RewriteRule ^ http://mydomain.pl/ [L,R]
I hope I have explained myself well.
Upvotes: 1
Views: 215
Reputation: 1474
You can try that:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^mydomain\.com$
RewriteRule ^pl/(.*)$ http://mydomain.pl/$1 [R=301,L]
The host name is always lower case so you don't need [NC] and maybe in your case you want to have permanent redirects so you can use R=301.
Upvotes: 1