如何更改默认网址。例如 www.example.com/index.php -> www.example.com
现在我想将其设置为 www.example.com/test.php。我应该在 php.ini 中进行更改吗?
如何更改默认网址。例如 www.example.com/index.php -> www.example.com
现在我想将其设置为 www.example.com/test.php。我应该在 php.ini 中进行更改吗?
假设您使用的是 apache,您可以通过DirectoryIndex
指令执行此操作。
查看文档。
DirectoryIndex test.php
在您的 .htaccess 或 httpd.conf
您可以将 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
您必须使用该DirectoryIndex
指令在 Apache 的配置中更改它。
例如(在正确的VirtualHost
部分):
DirectoryIndex test.php
虽然我不明白为什么在地球上想要这样做......