【问题标题】:PHP file gets downloaded instead of executingPHP文件被下载而不是执行
【发布时间】:2021-12-11 06:45:14
【问题描述】:

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

【问题讨论】:

  • github页面不是php托管
  • 我不知道 GitHub 页面不支持 PHP。谢谢!
  • 如果你想上传 PHP 文件,那么你可以使用 'Heroku' 代替。只是说,如果您在 Heroku 上使用 PHP,并且在部署 GitHub 存储库时遇到任何问题,那么创建一个“index.php”文件(如果您没有),这可能会解决您的问题。

标签: php windows xampp github-pages


【解决方案1】:

类似的解决方案可以在这里找到PHP xampp downloading my index.php instead of loading the page

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

AddHandler application/x-httpd-php54s .php

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

AddHandler application/x-httpd-php73 .php

适用于 PHP 7.3 版

【讨论】:

  • 在哪里可以找到 .htaccess 文件?
  • 如果不存在,您可以在项目的根目录中创建一个。
猜你喜欢
  • 2017-11-16
  • 2013-02-06
  • 1970-01-01
  • 1970-01-01
  • 2020-12-26
  • 2017-06-05
  • 2014-10-17
  • 2017-12-16
  • 2016-03-18
相关资源
最近更新 更多