2010-05-27 69 views
1

我有我的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它没有,我不能只是想出我们的原因。

回答

1

需要设置服务器识别默认索引。

我使用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> 
+0

thx的帮助,它终于在httpd.conf中出现问题。没有index.php作为预定的索引。 – diego 2010-05-28 18:34:58

1

你缺少引号empresaproductos

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

我要写这一点。 – mingos 2010-05-27 22:55:33

+0

丁!丁!我也是。有趣的 – Gutzofter 2010-05-28 00:23:32

1

检查包括路径您的服务器上,以确保包括()可以找到empresa.php和productos.php