【发布时间】:2011-02-25 17:12:46
【问题描述】:
我有一个 htaccess 问题。
我的目录结构如下:
/
HEADER.html
README.html
/stackoverflow/
/stackoverflow/.htaccess
.htaccess
ServerSignature Off
Options +Indexes
HeaderName /HEADER.html
IndexIgnore HEADER.html
ReadmeName /README.html
IndexIgnore /README.html
IndexOptions +FancyIndexing
AddCharset UTF-8 .txt
IndexIgnore *.xml
IndexIgnore *.php
我的主目录是 /stackoverflow/,当我通过浏览器导航到这个目录时,我在 /stackoverflow/ 下的每个站点/目录中都包含了 HEADER.html 和 README.html,这工作正常。
我向我的 HEADER.html(位于根目录 / )中添加了一些 php 代码,我正在尝试添加到 htaccess:
AddType application/x-httpd-php .html .php .htm
这不起作用,我认为是因为 HEADER.html 在根目录中。
如果我尝试将 AddType... 添加到 /.htaccess(而不是 /stackoverflow/.htaccess),它会覆盖我的 /stackoverflow/.htaccess 规则。为什么?如何将 AddType 规则添加到我的 /stackoverflow/.htaccess 以将 Apache 解析 html 文件作为 php 文件?
【问题讨论】: