Apply .htaccess HeaderName to all lower levels?

最后都变了- 提交于 2020-01-01 09:55:22

问题


I'm using the following .htaccess to spruce up my directory list:

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 .??* *~ *#

It loads header html which contains:

<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>

It looks great when I go to the folder /test/. However, when I go to /test/test2/ it doesn't pick up the previous htaccess, thus showing the boring default style. How can I make it stick/recursive for the lower laying subfolders as well?


回答1:


Place a / before header.html to tell Apache to look to the root everytime.

HeaderName /header.html

EDIT: If your header.html file doesn't exist in the root, change the path to be where you have stored the file.

HeaderName /path/to/header.html


来源:https://stackoverflow.com/questions/4604857/apply-htaccess-headername-to-all-lower-levels

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!