Hello,
I'm currently offering my clients on my web to have their own mini contact websites with a dynamic subdomain. The urls currently look like:
http://user.mydomain.com/website/
I have to use web/ to show .htaccess what I need, so it looks like this:
RewriteCond %{HTTP_HOST} ^(.*).mydomain.com$
RewriteCond %{REQUEST_URI} ^/website/.*
RewriteRule (.*) /client_websites/index.php [L]
What I want is to remove the /website/ prefix altogether, so that the client websites would have regular subdomains like:
http://user.mydomain.com/
And in addition, I want to force the www. prefix if the user is browsing the main website. So if the prefix is www. - display the website as normal, if there is no www. or subdomain - redirect to the same url only with www in front, and if not www. - use the client_websites/index.php to display the user content.
So what I need in .htaccess is to create a rule that checks if the HTTP_HOST (.*).mydomain.com is NOT www, and then use the same /client_websites/index.php, and then I'd add an additional check to make sure the subdomain exists.
Is this at all possible with mod_rewrite? I could force every page to go through a .php file to check if the subdomain is www or not, but that would obviously increase the server load dramatically.
Any tips would be helpful :) thanks!