For subdomains to work, you'll need to change your dns to translate said subdomain to your site. This is done with a CNAME record. Typically your DNS looks something like this:
Domain Type Target
example.com A 192.168.1.0
*.example.com CNAME example.com
*.example.com
will route this.example.com
and that.example.com
to the ip defined for example.com
, but this.other.example.com
is not matched by it. If you just want to have one subdomain, make a CNAME record for just that subdomain instead (not with a *).
In httpd.conf (this is the main config file for Apache, might be named differently on your operating system) make sure your subdomains are using the same document root. I am not familiar with this, but this might help according to this.
In .htaccess in your www-root have the following rule:
RewriteCond %{REQUEST_URI} !^/index\.php
RewriteCond %{HTTP_HOST} ^([^\.]+)\.example\.com$
RewriteRule ^(.*)$ /index.php/subdomain/category/%1/$1
This will internally rewrite somename.example.com/whatever/thing
to DOCUMENT_ROOT/index.php/subdomain/category/somename/whatever/thing
.