Codeigniter does not support domain routing as part of its default functionality.
If you visited www.example.com/controller/method , the router only interprets the /controller/method and ignores nothing before.
This means that in order to achieve what you are trying, you need to direct subdomains to the application using .htaccess.
RewriteCond %{HTTP_HOST} ^((?!www\.)(?!myapp\.com)[^\.]+)\. RewriteRule ^(.*)$ /index.php?/user/%1/$1 [L]
This will send all requests e.g.
subdomain.example.com/controller/method go to example.com/index.php/user/controller/method
This will allow you to route based on the subdomain using standard routing functionality.
source share