首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >禁用Apache上的目录索引?

禁用Apache上的目录索引?
EN

Server Fault用户
提问于 2011-11-18 13:07:26
回答 2查看 194关注 0票数 -1

我想禁用Apache上的目录索引。

这是我的.htaccess文件全文。但是,一旦我取消评论Options -Indexes,服务器就会崩溃。

我做错了什么?

代码语言:javascript
复制
#Options –Indexes

<IfModule mod_expires.c>

# Turn on the Expires engine
  ExpiresActive On

# CSS and JavaScript
  ExpiresByType text/css                  "access plus 1 hour"
  ExpiresByType application/javascript    "access plus 1 hour"

# Media: images
  ExpiresByType image/gif                 "access plus 1 month"
  ExpiresByType image/png                 "access plus 1 month"
  ExpiresByType image/jpg                 "access plus 1 month"
  ExpiresByType image/jpeg                "access plus 1 month"

# Webfonts
  ExpiresByType application/x-font-ttf    "access plus 1 month"
  ExpiresByType font/opentype             "access plus 1 month"
  ExpiresByType application/x-font-woff   "access plus 1 month"
  ExpiresByType image/svg+xml             "access plus 1 month"
  ExpiresByType application/vnd.ms-fontobject "access plus 1 month"

  <IfModule mod_headers.c>
    Header append Cache-Control "public"
  </IfModule>

</IfModule>
EN

回答 2

Server Fault用户

回答已采纳

发布于 2011-11-21 10:59:53

如果其他人遇到同样的问题,问题是我复制并粘贴了一行:

代码语言:javascript
复制
Options –Indexes

而Apache无法处理连字符的编码!

票数 2
EN

Server Fault用户

发布于 2011-11-18 13:23:19

可能您的Apache是在httpd.conf中配置的,AllowOverride设置为这样的值--它不允许您在.htaccess中优化任何选项。

您是否有权访问httpd.conf或Apache错误日志?

票数 2
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/332363

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档