Willian Keller
Willian Keller

Reputation: 429

Language URI redirect to Subdomain with Htaccess

I have a easy question for you... I need redirect a old URL with the possible content in URI, like that:

www.mywebsite.com/en
www.mywebsite.com/en/another-page

to

en.mywebsite.com
en.mywebsite.com/another-page

Somebody have a solution for this?

Thanks a lot!

Upvotes: 1

Views: 97

Answers (1)

anubhava
anubhava

Reputation: 785128

You can use this rule as your very first rule:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(?:www\.)?mywebsite\.com$ [NC]
RewriteRule ^en(?:/(.*))?$ /$1 [L,NC,R=301]

Upvotes: 1

Related Questions