Why does index.html have priority over index.php?

后端 未结 5 524
被撕碎了的回忆
被撕碎了的回忆 2020-11-30 05:48

I have a website on a server. The homepage is example.com/index.php .

OK, I uploaded an index.html named file to the server (the root dir) and when I typed in my sit

相关标签:
5条回答
  • 2020-11-30 06:19

    The biggest issue, as with all types of development, is maintenance. If you decide to change technology then by exposing the file extension you are setting yourself up for a lot of work - not to mention the security aspects of broadcasting your choice. The best situation is to avoid exposing extensions by using url rewriting.

    0 讨论(0)
  • 2020-11-30 06:33

    @kuroir is right, that depends on the web server configuration, in Apache it's the DirectoryIndex:

    DirectoryIndex index.html index.php index.cgi
    

    That will give priority to .html files over .php files, and priority to .php files over .cgi files.

    0 讨论(0)
  • 2020-11-30 06:34

    It really depends on the Server you're using. This is a matter of configuration. It's not that there's any advantage from using html vs php filetype.

    You could say that the .html variation takes precedence due to the fact that it's the most basic web format.

    If you're using Apache, just check the default .htaccess setup:

    DirectoryIndex index.html index.shtml index.php index.htm default.html Default.htm default.html Default.html default.shtml Default.shtml page1.html index.pl index.cgi index.php3 index.phtml home.htm home.html home.shtml index.wml
    

    You can edit that and make it fit your needs.

    0 讨论(0)
  • 2020-11-30 06:34

    I know this is old and has been accepted but I want to add to this in case someone else has this problem.

    I came here when looking for a solution to the same problem. Entering the Wordpress "index.php" into the URL got redirected to "index.html". It had nothing to do with the .htaccess. I finally found the solution in their forum. Wordpress modified the program a couple years ago to strip "index.php" from URLs. So then of course it goes to your default (usually index.html).

    To make it behave as you expect, you need to revert the change here: changeset 9203. See Forum topic

    0 讨论(0)
  • 2020-11-30 06:41

    Well it depends on your hosting provider well yes 90% hosting provider gives priority to index.html instead of index.php or any other extention.

    0 讨论(0)
提交回复
热议问题