扩展 PHP5 在 XAMPP 中不解析

2022-01-14 00:00:00 xampp php apache

我已经安装了 XAMPP Apache 服务器并将我的网站放入 htdocs.我已经启动了 Apache 服务器.在我的网站上,我有扩展名为 PHP 和扩展名为 PHP5 的文件.不同之处在于,当我在浏览器中输入 localhost/file.php 时,我看到了一个已解析的网站.

I've installed XAMPP Apache server and put my website into htdocs. I've started Apache server. On my website I've got files with extension PHP and with extension PHP5.The difference is that when I type in into browser localhost/file.php - I see a parsed website.

但是当我输入 localhost/file.php5(我在服务器上有这个文件)时,浏览器会询问我是否要下载或打开这个文件.如果我选择打开,我会看到 file.php5 的 PHP 代码!

But when I type localhost/file.php5 (i have this file on server), than browser asks me if I want to download or open this file. And if I choose open than I see PHP code of file.php5!

我已经查看了配置,所以:

I've looked into configuration, so:

  1. 我没有 htaccess 文件
  2. PHPINFO() 显示 PHP 5
  3. c:xamppapacheconfextrahttpd-xampp 包含在配置中,并且在开头有这个:

  1. I dont have htaccess file
  2. PHPINFO() shows PHP 5
  3. c:xamppapacheconfextrahttpd-xampp is included into configuration and has this on the beginning:

AddType application/x-httpd-php-source .phps

AddType application/x-httpd-php-source .phps

AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml .phpt

AddType application/x-httpd-php .php .php5 .php4 .php3 .phtml .phpt

我也尝试过:

AddHandler php5-script .php5
AddType text/html .php5

进入 httpd.conf,但它对我不起作用(没有变化).

Into httpd.conf, but it does not work for me (no changes).

你能帮我修一下吗?我想用 php5 解析器打开 php5 和 php 扩展文件.

Could you please help me fixing it? I would like to have php5 and php extension files to be opened with php5 parser.

推荐答案

XAMPP 默认将具有以下扩展名的文件传递给 PHP: .php .php5 .php4 .php3 .phtml .phpt (this使用 XAMPP Lite 1.6.8 进行了测试).

XAMPP passes by default files with the following extensions to PHP: .php .php5 .php4 .php3 .phtml .phpt (this was tested with XAMPP Lite 1.6.8).

我的建议是从 XAMPP 配置中删除AddType text/html .php5"行.或者,使用全新安装的 XAMPP 并查看差异(使用 WinMerge 之类的东西).

My suggestion would be to remove the "AddType text/html .php5" line from the XAMPP configuration. Alternatively, use a clean install of XAMPP and look at the differences (with something like WinMerge).

相关文章