views:

210

answers:

2

I am currently interpreting sub-domain wild-cards with php and i would like to handle them with .htaccess, user profiles will be accessed at http://username.mysite.com/ (or for some people http://www.username.mysite.com/) which should use /main.php?action=profile

The hardest part of this is making /error/i+am+a+test+message or /files/iamatestfile.jpg go to &error=i+am+a+test+message or &files=iamatestfile.jpg

Thanks for any and all help!

+2  A: 

Try:

 RewriteRule ^error/(.*) index.php?error=$1 [L]
 RewriteRule ^file/(.*) index.php?file=$1 [L]

... for the last two.

cdmckay
I need to have the cond for the subdomains first and make sure that its on a subdomain other then WWW before loading files.
um... yes... just put the RewriteCond directive twice, once before each rule.
David Zaslavsky
Yeah, add RewriteCond %{HTTP_HOST} !^www\.mysite\.com$ [NC] before each.
cdmckay
A: 

Try this:

# stop rewriting for the host names example.com and www.example.com
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$
RewriteRule ^ - [L]

RewriteRule ^error/(.*) index.php?error=$1 [L]
RewriteRule ^file/(.*) index.php?file=$1 [L]
Gumbo
awsome what about for wild-card subdomains, can you show me a cond/rule example for that? What I really wanted instead of error/ and file/ it to be dynamic (.*)/(.*)/ like variable/value/variable2/value2. Thanks!