2

如何更改默认网址。例如 www.example.com/index.php -> www.example.com

现在我想将其设置为 www.example.com/test.php。我应该在 php.ini 中进行更改吗?

4

4 回答 4

3

假设您使用的是 apache,您可以通过DirectoryIndex指令执行此操作。

查看文档

于 2011-01-13T22:22:51.010 回答
2
DirectoryIndex test.php

在您的 .htaccess 或 httpd.conf

于 2011-01-13T22:23:39.133 回答
1

您可以将 htaccess 设置DirectoryIndex为包含 test.php:

DirectoryIndex test.php index.php index.html

您还可以从 index.php 设置重定向:

header('Location: test.php'); //Must be before any content is sent out

重定向也可以从 htaccess 工作:

Redirect 301 index.php test.php

然而,最简单的做法是将 test.php 文件重命名为 index.php。为什么不这样做呢?:P

于 2011-01-13T22:26:01.540 回答
0

您必须使用该DirectoryIndex指令在 Apache 的配置中更改它。

例如(在正确的VirtualHost部分):

DirectoryIndex test.php 

虽然我不明白为什么在地球上想要这样做......

于 2011-01-13T22:23:20.047 回答