We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

[Solved] Incorrect BaseUrl

I am having an issue with dynamically determining the basepath within phalcon. I can do it through php but I want to know if there is something I am not understanding or missing.

my environment:

I am using userdir in apache document root is /home/rwilbert/workspace
phalcon project code is at /home/rwilbert/phalcon/public

the url for the site is https://localhost/~rwilbert/phalcon/public

the issue I have is that url->get('login') resolves to /public/login. I believe this is because $url->getBaseUrl() == '/publc'. I can call $url->setBaseUrl () to correct this but that is for every instantiation of the URL object + it would also have to be added to volt templates. Because the css paths are also incorrect.

So before I start writing volt functions, is there something I am missing?



404

baseUri is set in app/config/config.php.

You can solve this problem with this code in you services.php:

$di->set('url', function() {
    $url = new \Phalcon\Mvc\Url();
    $url->setBaseUrl('https://bla.com');

    return $url;
}, true);


6.9k

Thank you. I missed that in the routing documentation



1.3k

How to configure routing if my project is in foldername like: https://localhost/projectname/index.php

folder phalcon :

/.htaccess => rewrite ke /public/index.php /public/index.php

/projectname/ =>

./controllers ./models ./views

I use this setBaseUrl but route still goes wrong