【问题标题】:Protect static content in WordPress application, hosted on Bluehost保护托管在 Bluehost 上的 WordPress 应用程序中的静态内容
【发布时间】:2021-10-10 10:08:08
【问题描述】:

[对不起我的英语不好]

嗨!

我是 Angular 开发人员,不了解 WordPress。

我开发了一个小应用程序,并被客户要求将其上传到他的网站。

他的网站是一个 WordPress 网站,托管在 Bluehost 上。 因为 Angular 应用程序是客户端代码,所以我将文件(使用 cPanel 文件管理器)复制到站点文件夹内的子文件夹中,我可以成功地为它们提供服务。

但是现在,我必须保护我的应用程序。 也就是说:虽然整个网站对世界开放,但我的应用程序存储在一个子文件夹中,应该供组织内部使用,并且只对注册用户开放。

有什么方法可以使用 WordPress/Bluehost 基础设施来实现,而无需编写新的用户管理应用程序?

感谢您的帮助。

【问题讨论】:

  • 你的应用是纯客户端应用(html/js),没有服务器端代码(nodejs/php)?
  • 是的。出于讨论的目的,我的应用是index.html 文件,包含“Hello World”文本。

标签: php wordpress membership bluehost


【解决方案1】:

您可以使用 WordPress 的帐户系统对用户进行身份验证,这是最简单的方法。只需将您的 index.html 重命名为 index.php 并将代码添加到 index.php 的标题中即可

<?php
require_once __DIR__ . '/../wp-load.php';
// check if a wordpress user has logged in
if (!is_user_logged_in()) {
    $app_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
    // redirect to wordpress login page
    wp_redirect(wp_login_url($app_url), 302);
    exit;
}
?>
<!-- your code begin -->
<html>
my app content
</html>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-07-05
    • 1970-01-01
    • 2012-05-18
    • 1970-01-01
    • 1970-01-01
    • 2021-10-26
    • 1970-01-01
    相关资源
    最近更新 更多