0

我有一个像http://example.com这样的主域名,它运行了一个 laminas 应用程序,但有另一个像http://demo.example.com这样的子域。我的这个子域的文件存储在 mytask.xml 中。

文档根目录是 /home3/example/mytask ,我的 index.php 如下。当我点击子域时,我的 index.php 被下载,但如果我点击它以 index.html 文件(注意:html 文件)为目标,内容将正确显示。

我的问题 如何从子域(demo.example.com)运行我的 laminas 应用程序

我的代码

感谢您花时间看我的问题,我很感激

<?php

declare(strict_types=1);

use Laminas\Mvc\Application;
use Laminas\Stdlib\ArrayUtils;

/**
 * This makes our life easier when dealing with paths. Everything is relative
 * to the application root now.
 *//**
 * Display all errors when APPLICATION_ENV is development.
 */
chdir(dirname(__DIR__). '/../mytask/application');

// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server') {
    $path = realpath(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH));
    if (is_string($path) && __FILE__ !== $path && is_file($path)) {
        return false;
    }
    unset($path);
}
// Composer autoloading
include __DIR__ . '/../vendor/autoload.php';

if (! class_exists(Application::class)) {
    throw new RuntimeException(
        "Unable to load application.\n"
        . "- Type `composer install` if you are developing locally.\n"
        . "- Type `vagrant ssh -c 'composer install'` if you are using Vagrant.\n"
        . "- Type `docker-compose run laminas composer install` if you are using Docker.\n"
    );
}
// Retrieve configuration
$appConfig = require __DIR__ . '/../config/application.config.php';
if (file_exists(__DIR__ . '/../config/development.config.php')) {
    $appConfig = ArrayUtils::merge($appConfig, require __DIR__ . '/../config/development.config.php');
}
// Run the application!
Application::init($appConfig)->run();
4

0 回答 0