Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wildcard Subdomain Exceptions

I have a wildcard subdomain enabled and dynamically parse the URL by passing it as-is to my index.php (ex. somecity.domain.com).

Now, I wish to create a few subdomains that are static where I can install different application and not co-mingle with my current one (ex. blog.domain.com).

My .htaccess currently reads:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Can I manipulate this .htaccess to achieve what I need? Can it be done through Apache?

like image 830
GiladG Avatar asked Nov 14 '22 17:11

GiladG


1 Answers

Your .htaccess does nothing useful, as Apache is probably configured with DirectoryIndex index.php. Well, it does move domain.com/a to domain.com/index.php, but I doubt that is what you want.

Your wildcard virtualhost works because you probably have ServerAlias *.domain.com in your configuration, or a single virtualhost and DNS pointing to the address of your server. (When you have a single virtualhost, it shows up for any request, and the first listed virtualhost is the default one)

You have to create new VirtualHosts for the static domains, leaving the default one as, well, the default one :)

Check these tutorials that explain it all.

like image 187
Vinko Vrsalovic Avatar answered Nov 30 '22 22:11

Vinko Vrsalovic