When a user registers with my site I want to offer them a login page and a user area with the URL:
http://user1.mysite.com http://user2.mysite.com http://user3.mysite.com ...
I did a google search for this but I wasn't sure of the right terms...
How can I do this without having to actually create lots of subdomains - I am sure its not done this way - is it URL re-writing? Apache mod_rewrite?
If so can someone give me an example please or is there a better way of doing this?
Btw, I am using Codeigniter - if Codeigniter has something that can do this, I would rather use that.
Thanks all for any help
In your apache vhost definition (vhost.conf
or whatever you have configured), create a wildcard alias
<VirtualHost *:80>
ServerName mysite.com
ServerAlias *.mysite.com
Then when the user hits your page, parse their URL (using parse_url()) to provide the correct login page/get their attempted username etc. Don't forget to duplicate the alias to your *:443
VirtualHost definition if you need to.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With