0
votes

On my new site I want to have dynamic subdomains. I'm trying to make it so that the subdomains use the same web root as the main domain, all under a single CodeIgniter installation. For example, subdomain.example.com would lead to example.com/subdomain, which is actually example.com/index.php/subdomain.

I've already the DNS set up but I'm getting caught up on the .htaccess.

VirtualDocumentRoot /var/www/crashworks/public/%-3+ Is the line from my sites-available configuration just for completeness. This might also be the source of the issue.

The effect of the linked htaccess is that when navigating to any subdomain, it gets caught up in an infinite loop. (Error log after one request.) It's the same effect for www., which should just resolve to the main domain.

1

1 Answers

0
votes

Did you try

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteCond %{HTTP_HOST} ^([a-z0-9]+)\.example\.com$ [NC]
RewriteRule ^/(.*)$ index.php?url=%1&path=$1 [L,QSA]

Or something like this?