首页 > 解决方案 > PHP文件被下载而不是执行

问题描述

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

**<!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 页面。但它会被下载。

标签: phpwindowsxamppgithub-pages

解决方案


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

您必须在 .htaccess 文件中添加一个处理程序。

AddHandler application/x-httpd-php54s .php

不过,您必须将 php 版本更新为您的版本。例如

AddHandler application/x-httpd-php73 .php

适用于 PHP 7.3 版


推荐阅读