So, I want to create a subdomain for each client like:
user1.mydomain.com -> mydomain.com/users/user1
or at least
user1.mydomain.com -> mydomain.com
and I can grab the user1
part with php. Not a redirection, but a URL rewrite.
My problem is that this is just not working. This is my current configuration in the .htaccess
file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?([a-z0-9-]+)\.mydomain\.com [NC]
RewriteCond %{QUERY_STRING} !^/users/
RewriteRule ^(.*)$ /index.php?/users/%2/$1
# CodeIgniter Rules
RewriteCond $1 !^(index\.php|images|robots\.txt)
RewriteRule ^(.*)$ /index.php/$1 [L]
I have seen many answers about this but in my case nothing seems to work. I have also updated my domain zones file:
*.mydomain.com. A 000.000.000.000
What I see when typing something like user2.mydomain.com
is an error page from my hosting account, not a server error. As usual, any help will be much appreciated, I've been trying to figure out what's wrong for days now :P
Edit: It seems that the problem is more with the server configuration (Apache). If I type any subdomain, what it shows is a page from my hosting provider's server, not a server error (like 500, etc), just a page. The same page shown if I just type my website's IP in the URL bar, it goes to the default page of my hosting provider.
Thank you all for reading.