Index files for Subdomains

这一生的挚爱 提交于 2019-12-11 00:19:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!