Raheel
Raheel

Reputation: 177

url rewrite with htaccess, add parameter in start domain name

I've a problem in url rewriting. i want to rewrite my url that is currently displaying as domain.com/index.php?lang=fr
and i want to show it like
fr.domain.com

any help will be appereciated. Thanks

Upvotes: 1

Views: 569

Answers (1)

anubhava
anubhava

Reputation: 785316

Try this code on DOCUMENT_ROOT/.htaccess on domain.com:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteCond %{QUERY_STRING} (?:^|&)lang=([^&]+) [NC]
RewriteRule ^ http://%1.%{HTTP_HOST}%{REQUEST_URI}? [NE,R=301,L]

Upvotes: 1

Related Questions