Dynamic subdomain routing with .htaccess in CodeIgniter 3 |
Is it possible to route subdomains in a CodeIgniter 3 application using only .htaccess?
What I'm trying to achieve, as an example: I have mysite.localhost.com, and then I'll have multiple subdomains like client1.mysite.localhost.com, client2.mysite.localhost.com, and so on. I need mysite.localhost.com to point to my 'Home' controller, which will be a landing page. Then, I need all subdomains to point to mysite.localhost.com/client/, passing the subdomain as a parameter to the 'index' function of the 'client' controller. I've tried all I could think of, without luck. The following works using plain PHP, but not in CodeIgniter (maybe because of routes.php?), it gives a 500 Internal Server Error (I'm guessing a loop, but I can't figure out how to solve it): Code: RewriteCond %{HTTP_HOST} !^mysite\.localhost\.com$ [NC] To be clear, I need URL masking, not redirecting. Following the above examples, this is what I'm trying to achieve: Code: client1.mysite.localhost.com --> mysite.localhost.com/client/client1 And so on... Thanks in advance!
You can't add a subdomain in htaccess, look here:
https://stackoverflow.com/questions/1901...alhost-url |
Welcome Guest, Not a member yet? Register Sign In |