【发布时间】:2017-05-03 09:41:00
【问题描述】:
我需要两个 .htaccess 文件的帮助 - 一个在网络服务器的根目录中,第二个在子文件夹中。
根目录中的.htaccess 工作正常
/var/www
Options +FollowSymLinks MultiViews
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
.htaccess 在子目录中 - 不起作用
/var/www/子目录
AddType application/x-httpd-php .html
ExpiresActive On
ExpiresDefault A1
Header append Cache-Control must-revalidate
Apache 配置 - 我有两个虚拟主机 - 一个用于 80,第二个用于 443。 在 *80 中我有目录选项
<Directory /var/www/>
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
在子文件夹中我有 .html 文件,这个 htaccess 应该将它们视为 php。我错过了什么吗?
请注意 - 当我使用检查元素时,整个 PHP 代码都在 html 中注释。 PHP 5.6 Apache 2.4.0
【问题讨论】:
-
您确认
AddType application/x-httpd-php .html是您服务器的正确指令吗?Cache-Control没有设置?你需要MultiViews吗? -
嗨,是的 AddType application/x-httpd-php .html 这是正确的。无论如何我解决了我的问题,请参阅下面的答案。