将 index.html 设为默认值,但如果输入,则允许访问 index.php [英] Make index.html default, but allow index.php to be visited if typed in

查看:26
本文介绍了将 index.html 设为默认值,但如果输入,则允许访问 index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 .htaccess 文件中有以下行:

I have the following line in my .htaccess file:

DirectoryIndex index.html index.php

每次我去 index.php 都会带我去 index.html.是否可以同时允许,但将 index.html 保留为访问 www.domain.com 的用户的默认值?

Everytime I go to index.php it takes me to index.html. Is it possible to allow for both, but leave index.html the default for users visiting www.domain.com?

推荐答案

默认情况下,DirectoryIndex 设置为:

By default, the DirectoryIndex is set to:

DirectoryIndex index.html index.htm default.htm index.php index.php3 index.phtml index.php5 index.shtml mwindex.phtml

Apache 将按顺序查找上述每个文件,并在访问者仅请求目录时提供它找到的第一个文件.如果 Web 服务器在当前目录中找不到与 DirectoryIndex 指令中的名称匹配的文件,则会向浏览器显示目录列表,显示当前目录中的所有文件.

Apache will look for each of the above files, in order, and serve the first one it finds when a visitor requests just a directory. If the webserver finds no files in the current directory that match names in the DirectoryIndex directive, then a directory listing will be displayed to the browser, showing all files in the current directory.

顺序应该是DirectoryIndex index.html index.php//默认是index.html

The order should be DirectoryIndex index.html index.php // default is index.html

参考: 这里.

这篇关于将 index.html 设为默认值,但如果输入,则允许访问 index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆