Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache 您可以更改特定目录的DirectoryIndex吗?_Apache_.htaccess_Directoryindex - Fatal编程技术网

Apache 您可以更改特定目录的DirectoryIndex吗?

Apache 您可以更改特定目录的DirectoryIndex吗?,apache,.htaccess,directoryindex,Apache,.htaccess,Directoryindex,我知道您可以在.htaccess中使用directoryindexample.html,但我需要的是更改特定目录的索引,如下所示: DirectoryIndex /ex/index_file.html 或 你有没有办法做到这一点?我不想将我尝试执行此操作的文件重命名为index.html,因为它不是这样的。你需要先登录,如果你没有登录,它会重定向你;但是我认为这看起来很草率。您可以在每个目录中创建一个.htaccess,您需要在其中创建不同的目录索引。ex目录中的.htaccess应包含: D

我知道您可以在.htaccess中使用
directoryindexample.html
,但我需要的是更改特定目录的索引,如下所示:

DirectoryIndex /ex/index_file.html


你有没有办法做到这一点?我不想将我尝试执行此操作的文件重命名为index.html,因为它不是这样的。你需要先登录,如果你没有登录,它会重定向你;但是我认为这看起来很草率。

您可以在每个目录中创建一个.htaccess,您需要在其中创建不同的目录索引。
ex
目录中的.htaccess应包含:

DirectoryIndex index_file.html
DirectoryIndex index_file2.html
但是
ex2
中的on应该包含:

DirectoryIndex index_file.html
DirectoryIndex index_file2.html
您还可以在web根目录中的.htaccess中使用,只要允许您覆盖此项:

<Directory ex>
   DirectoryIndex index_file.html
</Directory>

<Directory ex2>
    DirectoryIndex index_file2.html
</Directory>

DirectoryIndex_file.html
DirectoryIndex_file2.html

您可以在每个需要不同目录索引的目录中创建.htaccess。
ex
目录中的.htaccess应包含:

DirectoryIndex index_file.html
DirectoryIndex index_file2.html
但是
ex2
中的on应该包含:

DirectoryIndex index_file.html
DirectoryIndex index_file2.html
您还可以在web根目录中的.htaccess中使用,只要允许您覆盖此项:

<Directory ex>
   DirectoryIndex index_file.html
</Directory>

<Directory ex2>
    DirectoryIndex index_file2.html
</Directory>

DirectoryIndex_file.html
DirectoryIndex_file2.html

我的意思是,假设我有两个单独的目录
dir1
dir2
。对于
dir1
我希望目录索引为
example.html
,对于
dir2
我希望目录索引为
另一个示例.html
。这有用吗?哦,明白了,我想你可以在下面读答案,我想应该是这样的,我的意思是,假设我有两个单独的目录
dir1
dir2
。对于
dir1
我希望目录索引为
example.html
,对于
dir2
我希望目录索引为
另一个示例.html
。这有用吗?哦,明白了,我想你可以在下面读答案,我想它应该能解决我的问题。:)我想你也许能做到,我想我应该在发帖之前试一下;哦,好吧。谢谢你的帮助!这解决了我的问题我想你也许能做到,我想我应该在发帖之前试一下;哦,好吧。谢谢你的帮助!