【问题标题】:Basic help to execute html file containing php .htaccess file config [duplicate]执行包含 php .htaccess 文件配置的 html 文件的基本帮助 [重复]
【发布时间】:2019-04-02 04:28:16
【问题描述】:

目标: 执行包含 PHP 命令的 HTML 文件(例如 this,这只是一个基本的演示脚本。我得到的唯一输出是 Welcome to my home 1page,来自 PHP 的 hello world 没有运行)

如果我可以让它运行,我有 PHP 从数据库中提取数据。

问题: 尽管更改了位于butlinsminehead.co.uk 根域的.htaccess 文件,但我添加的任何内容都没有任何效果。我有很多选择

including AddHandler php-fastcgi `.php` `.php5` `.php72`
AddType text/html `.php .php5 .php72`
DirectoryIndex index.php index.php5 index.php72

我相信我正在运行 php7,虽然这是输出:

System  Linux zebedee3.namesco.net 2.6.32-754.6.3.el6.x86_64 #1 SMP Tue Oct 9 17:27:49 UTC 2018 x86_64
Build Date  Sep 20 2016 12:10:20
Server API  CGI/FastCGI

请问有人知道 .htaccess 文件应该包含什么吗?

HTML 正在butlinsminehead.co.uk 的子域中运行

【问题讨论】:

  • AddHandler php70-script .php .php5 .html .htm

标签: php html .htaccess


【解决方案1】:

您需要设置正确的类型,即application/x-httpd-php 而不是text/html

您可以阅读 AddType 指令,因为 *X 类型由 Y 文件处理,因此:

AddType text/html .php .php5 .php72

将是 HTML 类型由 PHP 文件处理,而您想要的是 PHP 类型由 HTML 文件处理

AddType application/x-httpd-php .php .php5 .php72

如果不起作用,请尝试使用 application/x-httpd-php5

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-05-09
    • 2011-03-28
    • 1970-01-01
    • 1970-01-01
    • 2013-12-04
    • 2018-04-12
    • 1970-01-01
    • 2011-02-19
    相关资源
    最近更新 更多