默认情况下不加载index.php


index.php is not loaded by default

我的地址是"http://www.dopsfest.com".

以这种方式编写,它显示javascript文件(index.js)

如果我在地址中添加"/index.php",它将正确显示,即加载了-index.php。

我尝试了php:

$address = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$stack = explode('/', $_SERVER["REQUEST_URI"]);
$file = array_pop($stack);
$folder = array_pop($stack);
if ($file =="") {header('Location: http://www.dopsfest.com/index.php');}

没有成功。

为什么我需要写"index.php"
在localhost和另一个远程服务器上,它可以在不添加"index.php"

的情况下工作

Apache

在项目根目录下创建一个.htaccess文件,并将其放入:

DirectoryIndex index.php

Nginx

$ cd /etc/nginx/sites-available/default

索引Index.html Index.htm,Index.php;

Lighttpd

$ nano /etc/lighttpd/lighttpd.conf

index-file.names = ( "index.php", "index.html" )