Php 包含和不处理索引

Php 包含和不处理索引,php,include,get,root,Php,Include,Get,Root,我的index.php有一个问题,我有一个小脚本来决定要交付什么内容 <?php $clase = $_GET['clase']; if ($clase == empresa) {include ("empresa.php");} elseif ($clase == productos) {include("productos.php");} else {include ($_SERVER['DOCUMENT_ROOT']."/inicio.html"); } ?>

我的index.php有一个问题,我有一个小脚本来决定要交付什么内容

        <?php $clase = $_GET['clase'];
if ($clase == empresa) {include ("empresa.php");}
elseif ($clase == productos) {include("productos.php");}
else {include ($_SERVER['DOCUMENT_ROOT']."/inicio.html"); }
?>

当我访问www.mysite.com/index.php时,它会起作用


但是,当我访问www.mysite.com时,它并没有,我也无法找到我们的原因。

您在
empresa
productos
中遗漏了引号:

<?php $clase = $_GET['clase'];
if ($clase == 'empresa') {include ("empresa.php");}
elseif ($clase == 'productos') {include("productos.php");}
else {include ($_SERVER['DOCUMENT_ROOT']."/inicio.html"); }
?>


检查服务器上的include路径,确保include()可以找到empresa.php和productos。php需要设置服务器以识别默认索引

我使用Apache,在httpd.conf文件中,您需要更改
DirectoryIndex

这是我的副本:

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.php index.htm index.html
</IfModule>
#
#DirectoryIndex:设置Apache在目录
#请求。
#
DirectoryIndex.php index.htm index.html

我也正要写这个。为了得到帮助,httpd.conf中终于出现了一个问题。没有将index.php作为预先确定的索引。