开发者

Wildcard DNS with URI Request

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 al开发者_StackOverflowl this information to one PHP or do I need to create a directory for every user?

Thanks for your help.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜