Mvd
Mvd

Reputation: 25

htaccess rewrite suffix /lang/en to subdomain 301

I've recently created a subdomain for my english language equivalent on my site and now want to rewrite the old urls to that subdomain.

the old url looks like http://mydomain.com/filename/lang/en

I want to redirect ALL the urls that end with /lang/en to the subdomain e.g. http://en.mydomain.com

Upvotes: 0

Views: 166

Answers (1)

Justin Iurman
Justin Iurman

Reputation: 19016

If you want http://mydomain.com/filename/lang/en to be redirected to http://en.mydomain.com/filename put this code in your htaccess

RewriteEngine on
RewriteRule ^(.+)/lang/en$ http://en.mydomain.com/$1 [R=301,L]


Otherwise, if you want http://mydomain.com/filename/lang/en to be redirected to http://en.mydomain.com put this code in your htaccess

RewriteEngine on
RewriteRule ^(.+)/lang/en$ http://en.mydomain.com [R=301,L]

Upvotes: 1

Related Questions