I'm using a system called ISPconfig to manage my sites, and then "hand coding" in some redirects afterwards.
The system automates everything in the config up until the
location ~ \.php$ {
block, after which you can add more directives.
I have:
/weather/index.html ... and a few other subdomain roots.
I also have
/subdomainscript/index.php
as a catchall which allows me to wildcard subdomains and base their content on the subdomain.
ie: cheese.mydomain.com might say "Here's some info on cheese".
ISPconfig sets up the following:
index index.html index.htm index.php index.cgi index.pl index.xhtml;
But while weather.mydomain.com works because the index is a plain .html file, any redirects to subdomainscript, which has index.php in its root, doesn't. If I manually add index.php to the end, it works. And if I drop a plain html file, it reads that just fine. But otherwise, it doesn't work.
UNLESS I change the index directive to be:
index index.php index.html index.cgi index.pl index.xhtml;
This is weird, because I thought the idea was that it tried each one in turn? But it seems to not find index.html, then go straight to 404.
Of course, I can change that manually, but each time I make any other change through ISPconfig, it will get reverted, so it's not ideal.
Here's the other relevant part of my config file, if it helps. Am I doing something wrong?
if ($http_host ~* "^weather\.(.*)") {
rewrite ^/(.+)$ /weather/$1 break;
}
if ($http_host ~* "^find\.(.*)") {
rewrite ^/(.+)$ /find/$1 break;
}
if ($http_host ~* "^upload\.(.*)") {
rewrite ^/(.+)$ /tnupload3/$1 break;
}
if ($http_host !~* www\.(.*)|find\.(.*)|upload\.(.*)|weather\.(.*)) {
rewrite ^/(.+)$ /subdomainscript/$1 break;
}