Home
Position: 主页>apache>

remapping dynamic subdomain

Time:2010-01-20 05:22soucre:未知 作者:admin click:clicks
Hi, I'm working on a web app and want to be able to offer my users a URL such as: username.mydomain.com but have it map to: mydomain.com/controller/method/username FYI, I'm using codeigniter PHP framework, which should explain the above URL I need to

   Hi, I'm working on a web app and want to be able to offer my users a URL such as:

username.mydomain.com

but have it map to:

mydomain.com/controller/method/username

FYI, I'm using codeigniter PHP framework, which should explain the above URL I need to map to.

I'm thinking this should be done with mod_rewrite, and I've tried various method to no avail. Any ideas on how to go about this?

Thanks for any insights!

Greg ||| I'm afraid you'll likely need access to the server's setup. No idea how you'd go about it, though. ||| Hey Markus,

I have a vps, so I can do what ever. I'm just not sure exactly how to set it up. I added a wildcard domain, so all subdomains resolve, I just need the .htaccess to pick up the slack.

I actually had something working OK, but it redirected all subdomains. There are some I do not want redirected, like the main application, the demo version, the dev version, etc...all which are on their own subdomain.

So I need like a list of domains not to remap, and anything else should get kicked to a specific url.

Thanks for your reply!

Greg ||| You can use the RewriteCond stuff for that. Something like this (untested):

Expand|Select|Wrap|Line Numbers ||| Hey no problem Markus, I appreciate your input. Ok, so it's fairly simple it looks like, I think the hardest part is figuring out how to phrase the google query to find what I'm looking for. I should have guessed it would be ! (not) this domain.

I'll see what I can work out with this. Thanks again!

Greg ||| I think my above syntax is correct. For multiple sites, you could do this:

Expand|Select|Wrap|Line Numbers ||| i just spent all day trying to figure this one out for myself. i started off not even knowing how to use regex to feeling like a guru on this one. i pieced this information from the internet and it has nothing to do with codeigniter but it works for me. like i said i'm still a beginner so any critique of this code is welcome

Expand|Select|Wrap|Line Numbers

------line----------------------------
Recommend
Hottest