简体   繁体   English

Phalcon PHP不路由子域

[英]Phalcon PHP not routing for subdomain

I have one website, let's call it www.main.com, which is located on the server at /home4/username/public_html/main. 我有一个网站,我们叫它www.main.com,它位于服务器上的/ home4 / username / public_html / main。 This site is running Phalcon PHP with no issues at all. 该站点正在运行Phalcon PHP,完全没有问题。

Now I have made a subdomain, let's call it test.main.com, and used cPanel to set the route for the subdomain to /home4/username/testsite/test. 现在,我已经创建了一个子域,我们将其称为test.main.com,并使用cPanel将子域的路由设置为/ home4 / username / testsite / test。 This is where the problem is. 这就是问题所在。

Both /public_html and /testsite have their own .htaccess files containing the following: / public_html和/ testsite都有自己的.htaccess文件,其中包含以下内容:

test site: 测试地点:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule  ^$ test/public/    [L]
    RewriteRule  ((?s).*) test/public/$1 [L]
</IfModule>

main site: 主要网站:

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule  ^$ main/public/    [L]
  RewriteRule  ((?s).*) main/public/$1 [L]
</IfModule>

And testing the test site locally via XAMPP it works fine (currently just a very VERY simple Phalcon test page). 并且通过XAMPP在本地测试测试站点可以正常工作(当前只是一个非常简单的Phalcon测试页面)。 But when I upload the exact same site to the server phalcon errors with: PhalconException: IndexController handler class cannot be loaded 但是,当我将完全相同的站点上传到服务器时,出现以下错误: PhalconException: IndexController handler class cannot be loaded

The dispatch index.php file for the (non-working) test subdomain site contains the following: (无效的)测试子域站点的dispatch index.php文件包含以下内容:

<?php

try {
    //Register an autoloader
    $loader = new \Phalcon\Loader();
    $loader->registerDirs(array(
       '../app/controllers/',
       '../app/models/'
    ))->register();

    //Create a DI
    $di = new Phalcon\DI\FactoryDefault();

    //Setup the view component
    $di->set('view', function(){
       $view = new \Phalcon\Mvc\View();
       $view->setViewsDir('../app/views/');
       return $view;
    });

    //Setup a base URI
    $di->set('url', function(){
       $url = new \Phalcon\Mvc\Url();
       $url->setBaseUri('/test/');
       return $url;
    });

    //Handle the request
    $application = new \Phalcon\Mvc\Application($di);

    echo $application->handle()->getContent();

} catch(\Phalcon\Exception $e) {
    echo "PhalconException: ", $e->getMessage();
    echo "<br /><br /><strong>Trace Stack</strong>: ", $e->getTraceAsString();
}

Now this is baffling, as I said, there's no reason code wise the Phalcon project is wrong, as it works fine locally. 就像我说的那样,现在这令人莫名其妙,Phalcon项目没有代码明智的错误,因为它在本地可以正常工作。 So the only thing I can think of is somehow the routing of the subdomain is screwing things up, but I have no idea how, or how to fix it? 因此,我唯一能想到的就是子域的路由将事情搞砸了,但是我不知道如何或如何解决?

So it turned out to be something really simply stupid. 因此,事实证明这确实是愚蠢的。 For some reason using phalcon locally via XAMPP on Windows allowed me to use indexController.php as a controller name. 由于某些原因,在Windows上通过XAMPP在本地使用phalcon允许我使用indexController.php作为控制器名称。 However, when uploaded to the Apache server the name needed to be capitalised in full camel case to IndexController.php to work. 但是,当将其上载到Apache服务器时,需要使用全大写的大小写形式将名称大IndexController.php才能起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM