My domain is meeting.com
.
I work with PHP, jQuery, for the main part. No ASP.
When a user creates an account, I'd like a subdomain user.meeting.com
to be created for REDIRECTION purposes only. I don't want the subdomain to exist for real.
When someone would load john13.meeting.com
, I would like the website to redirec开发者_如何学编程t to meeting.com?user=john13
(I don't care if john13.meeting.com
remains in the URL bar).
What is the most efficient and easy method of doing it automatically in PHP or Apache? Please consider performance too since I have many users.
You don't need PHP for that. The right Apache configuration with the rewrite module on, will do the trick.
For example (not tested):
RewriteCond %{HTTP_HOST} !^www\.meeting\.com?$
RewriteCond %{HTTP_HOST} ^([^.]+)\.meeting\.com?$
RewriteRule ^$ /user/%1 [L]
Or if you're not rewriting further for SEO, the rule could be
RewriteRule ^$ /index.php?user=%1 [L]
For more inspiration, check out the link Shef posted with another example of how to achieve this.
精彩评论