vkGunasekaran
vkGunasekaran

Reputation: 6814

country based redirection in htaccess


I want to redirect this url :

www.example.com/index.php?cn=us

to

www.example.com/us/ 

is it possible in htaccess? and how?

Upvotes: 0

Views: 667

Answers (1)

Jeremy Conley
Jeremy Conley

Reputation: 934

Try this:

RewriteEngine On
RewriteRule ^([a-z]{2})/?$ index.php?cn=$1

And this shows this works with any two letter country code

index.php

<?php
echo $_GET['cn'];
?>

Upvotes: 3

Related Questions