【问题标题】:Apply .htaccess HeaderName to all lower levels?将 .htaccess HeaderName 应用于所有较低级别?
【发布时间】:2011-01-05 14:00:43
【问题描述】:

我正在使用以下 .htaccess 来修饰我的目录列表:

Options +Indexes
IndexOptions IgnoreCase FancyIndexing FoldersFirst NameWidth=* DescriptionWidth=* SuppressHTMLPreamble
HeaderName header.html
IndexIgnore header.html footer.html favicon.ico .htaccess .ftpquota .DS_Store icons *.log *,v *,t .??* *~ *#

它加载包含以下内容的标题html:

<html><head><title>My Stuff</title>
<style type="text/css">
body {
    background: #eee;
    margin: 33px;
    color: #333;
    }
h1 {
    font: 2.0em Georgia, serif;
    }
h1 a:hover, h1 a:active {
    text-decoration: none;
    }
a:link {
    text-decoration: none;
    color: #555;
    }
a:visited {
    text-decoration: none;
    color: #777;
    }
a:hover, a:active {
    text-decoration: underline;
    color: maroon;
    }
pre {
    font: 0.9em/1.3em "Courier New", Courier;
    margin: 3px 0;
    color: #777;
    }
pre img {
    display: inline;
    }
img {
    margin: 3px 0;
    }
</style>
</head>
<body><h1><a href="/test" title="My Atlassian Stuff">My Stuff</a></h1>

当我转到文件夹 /test/ 时,它看起来很棒。但是,当我转到/test/test2/ 时,它并没有拾取以前的 htaccess,从而显示出无聊的默认样式。我怎样才能让它对下层的子文件夹也有粘性/递归?

【问题讨论】:

    标签: apache .htaccess


    【解决方案1】:

    header.html 之前放置一个/ 以告诉Apache 每次都查找根目录。

    HeaderName /header.html
    

    编辑:如果根目录中不存在 header.html 文件,请将路径更改为您存储文件的位置。

    HeaderName /path/to/header.html
    

    【讨论】:

    • 男人中的神,你就是这样 :-) 谢谢!
    • 注意:在我们的服务器上,我必须改用HeaderName /~username/header.html,其中username是我的用户名(在Apache 2.4.29上)。同样,我必须在标题中使用 &lt;link rel="stylesheet" href="/~username/style.css"&gt; 才能正确包含我的 CSS。
    猜你喜欢
    • 2016-04-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-18
    相关资源
    最近更新 更多