Take the 2-minute tour ×

here is my sample url:


i want to rewrite it this way:


i tried

RewriteEngine on

RewriteBase /folder/subfolder/

RewriteRule ^([A-Za-z0-9\\-\\.]+)$ index.php?site=$1 [L]

i printed the array $_GET and returns the value of the 'site' parameter as 'index.php', it didn't return 'www.othersite.com'

how can this be done?


share|improve this question
To use . in a regex, you can escape it with \. but in your case, I don't see what is your problem with dots. –  Charles Brunet Apr 28 '11 at 2:10
RewriteRule ^([A-Za-z0-9-_-]+)$ index.php?site=$1 [L] this works fine if the value of the parameter 'site' has no .(dot or period) –  scoohh Apr 28 '11 at 2:28
Sorry I misunderstood your requirement and provided you opposite solution earlier. Please see my answer below, it should work for you. –  anubhava Apr 28 '11 at 3:53
thanks anubhava it woks! –  scoohh Apr 28 '11 at 4:47

1 Answer 1

up vote 0 down vote accepted

Try this rule in your .htaccess file:

Options +FollowSymlinks -MultiViews
RewriteEngine on

RewriteCond %{QUERY_STRING} !^site= [NC]
RewriteRule ^(folder/subfolder)/(.*)$ /$1/index.php?site=$2 [L,NC,QSA]
share|improve this answer

Your Answer


