PHP文件被下载而不是执行



我已经在GitHub上托管了我的网站。它加载第一个页面。但是当从该链接点击另一个页面时,它被下载。我正在使用PHP从XAMPP在Windows。

**<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<a href="login.php">Login as Staff</a>

</body>
</html>**

这是第一页。它应该转到login.php页面。但是它被下载了。

类似的解决方案可以在这里找到PHP xampp下载我的index.php而不是加载页面

你必须在你的。htaccess文件中添加一个处理器。

AddHandler application/x-httpd-php54s .php

你必须将php版本更新到你的版本。例如

AddHandler application/x-httpd-php73 .php

for PHP version 7.3

我遇到了同样的问题。这件事困扰了我4天。

我使用了visual studio和live server。当我单击实时服务器时,生成的地址是http://localhost:5500/index.html。这个地址导致php文件被下载而不是执行。将其更改为http://127.0.0.1/gre/index.html后,将正确执行索引页链接到的php文件。

在我的情况下,index.html文件在htdocs/gre/index.html中,所以我必须使用http://127.0.0.1/gre/index.html

访问它如果你的索引页在htdocs中的某个文件夹中,你必须在url中添加该文件夹的名称。

我真不敢相信这件小事花了我这么长时间才弄明白……

最新更新