tags:

views:

28

answers:

1

Hi!

I wish to rewrite admin.example.com/test/ to admin.example.com/index.php?site=test.

I have done ample research and have yet to be able to do so. Regex is not my thing, anyone have suggestions?

(in this particular example, only 'test' is a variable (i.e. 'admin' is constant'))

Thanks!

A: 

You could use mod_rewrite to do so:

RewriteEngine on
RewriteRule ^([^/]+)/$ index.php?site=$1

And if you want to restrict that rule to admin.example.com, add this condition:

RewriteEngine on
RewriteCond %{HTTP_HOST} =admin.example.com
RewriteRule ^([^/]+)/$ index.php?site=$1
Gumbo
Thanks, that worked flawlessly! :)
David Chouinard
if it worked flawlessly, please accept the answer by clicking on the outline of the "tick mark" on the left...
pǝlɐɥʞ