加载index.php作为我在php中的第一页
如何在我的php项目中让index.php成为项目加载的第一页而不是index.html您可以通过加载index.php作为我在php中的第一页,php,apache,Php,Apache,如何在我的php项目中让index.php成为项目加载的第一页而不是index.html您可以通过htaccess 在htaccess文件中编写以下代码 DirectoryIndex index.php 在apache.conf中搜索DirectoryIndex,并确保index.php位于index.html之前。像这样: DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm 如果您没有访问
htaccess
在htaccess
文件中编写以下代码
DirectoryIndex index.php
在apache.conf中搜索
DirectoryIndex
,并确保index.php位于index.html之前。像这样:
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
如果您没有访问apche配置的权限,或者不想全局设置这一行,您也可以将这一行添加到.htaccess文件中,因此有一个很好的解释,要执行OP要求的操作,您必须在Apache中使用
DirectoryIndex
。在站点配置或.htaccess中,必须放置以下内容:
DirectoryIndex index.php
这就告诉apache将index.php
作为主文件启动。因此,加载domain.tld/
确实会加载index.php
DirectoryIndex index.php index.html
这将加载index.php
,但如果不存在,它将尝试加载index.html
。列出的文件顺序是apache首先查找的
更多详细信息您可能真正想要的是针对Apache的解决方案,而不是PHP。除非你正在使用IIS或其他东西?获得帮助的最佳方式是能够回答?还有,你做了什么研究?研究感谢.htaccess提示!:)@hek2mgl欢迎您:)