Reputation: 4537
Just started using Phalcon, and found some strange error.
Here is my code in public/index.php
<?php
use Phalcon\Loader;
use Phalcon\Mvc\View;
use Phalcon\Mvc\Application;
use Phalcon\Di\FactoryDefault;
use Phalcon\Mvc\Url as UrlProvider;
use Phalcon\Db\Adapter\Pdo\Mysql as DbAdapter;
// Register an autoloader
$loader = new Loader();
$loader->registerDirs(
[
"../app/controllers/",
"../app/models/",
]
);
$loader->register();
// Create a DI
$di = new FactoryDefault();
// Setup the view component
$di->set(
"view",
function () {
$view = new View();
$view->setViewsDir("../app/views/");
return $view;
}
);
// Setup a base URI so that all generated URIs include the "bot" folder
$di->set(
'url',
function() {
$url = new \Phalcon\Mvc\Url();
$url->setBaseUri('/bot/');
return $url;
}
);
$application = new Application($di);
try {
// Handle the request
$response = $application->handle();
$response->send();
} catch (\Exception $e) {
echo "Exception: ", $e->getMessage();
}
According to this, my path should be localhost/bot/
.
But, when I type it in, I get this
So, when I navigate to localhost/bot/public/
, I get the desired output.
Why is it not behaving the way as given in the website?
Upvotes: 0
Views: 187
Reputation: 1369
You need .htaccess
in bot directory which will pass all requests to public/index.php
Something like:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule ((?s).*) public/$1 [L]
</IfModule>
Or similar nginx configuration.
Upvotes: 2