问题
I was finally able to setup subdomains but now I have a problem when I try and access the subdomain by itself. For instance, when I visit sub.domain.com, I get a page not found error. However, when I visit sub.domain.com/index.php, I see my page.
My theory is that when I visit sub.domain.com, the index file it searches for is not in the sub/ folder but instead in the root folder. I have directoryindex to look for index.html before index.php. There is a index.html in the root directory that is needed. So when I go to sub.domain.com, it thinks that sub.domain.com/index.html exists but then finds out it doesnt and sends me a 404. That is my theory. How would I fix this? Any ideas? Thanks.
回答1:
I'm assuming that you are using an apache server.
DirectoryIndex directive allows you to specify a specific filename or filenames as the default page in a directory.
There in a line the the configuration file which will say this:
DirectoryIndex index.html
Add the following
DirectoryIndex index.php index.html
This will specify the order of precedence for the default page of the subdomain. In the case index.php then index.html
The sub domain should then go to the correct index page if it does not find index.php it will take the
来源:https://stackoverflow.com/questions/2980232/index-files-for-subdomains