tags:

views:

43

answers:

2

So here is my problem. I want to redirect name.domain.com/trips/1 to domain.com?username=name&trip=1 using modrewrite. Is this possible? I have the dns set up correctly however - I am unsure about the htaccess file. Can I link all this information to one PHP or do I need to create a directory for every user?

Thanks for your help.

A: 

you don't have either to link or to create, as you already have domain name in PHP
see phpinfo(32); for more info

so, the only thing you need is redirect all trips to index, very usual task and SO has many solutions already I am sure.

Col. Shrapnel
+1  A: 

This is how I'd should do it with mod_rewrite:

Redirect permanent ^([a-z]+).*/([0-9]+)$ domain.com?username=$1&trip=$2

This will pick up things like

bob.domain.com/trips/1
ted.domain.com/trips/123

And translate them to:

domain.com?username=bob&trip=1
domain.com?username=ted&trip=123

Hope it helps

Marcos Placona
What about if the user adds the www piece to the front?
That you will need to treat separately.
Marcos Placona