如何用.htaccess中的不同文件替换index.html
当我浏览到如何用.htaccess中的不同文件替换index.html,.htaccess,.htaccess,当我浏览到http://www.example.com我想被重定向到http://www.example.com/home.html 当我浏览到http://www.example.com/index.php我想被重定向到http://www.example.com/index.php 我该怎么做呢?Hy, 只需在.htaccess文件中添加以下行 DirectoryIndex something.html 其中something.html将成为您的索引页 作为额外说明-请参阅文档中有关如何管
http://www.example.com
我想被重定向到http://www.example.com/home.html
当我浏览到http://www.example.com/index.php
我想被重定向到http://www.example.com/index.php
我该怎么做呢?Hy,
只需在.htaccess文件中添加以下行DirectoryIndex something.html
其中something.html将成为您的索引页作为额外说明-请参阅文档中有关如何管理.htaccess文件的内容。查看
DirectoryIndex
命令:
它允许配置在请求目录时尝试哪些文件。它还允许添加几个要尝试的选项。这允许灵活性,同时您仍然可以控制选项。当请求仅指定目录的URL时 例如:
http://www.domain.com/directory/
Apache默认情况下会查找文件名(按文件名出现的顺序):
index.html
index.htm
home.html
欢迎光临。html
.htaccess
指令DirectoryIndex
可用于覆盖此行为。在.htaccess
文件中,键入以下行:
DirectoryIndex.php index.html
当我输入www.example.com/index.php时,它会重定向到www.example.com/index.php
这意味着它们是什么?我尝试过使用DirectoryIndex home.html,但当我输入www.example.com/index.php时,它也会重定向到www.example.com/home.html,当我输入www.example.com/index.phpDo时,我想重定向到www.example.com/index.php。您是否有任何现有规则或安装了一些CMS/php?我已安装wordpress,然后发布您当前的.htaccess代码。我已尝试使用DirectoryIndex home.html,但是当我输入www.example.com/index.php时,它会重定向到www.example.com/home.html。您的home.html在服务器的第一级吗?如果它在另一个文件夹中,这将不起作用是的,它在第一级