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

URL Problem

Hello I'm learning Phalconphp and i'm facing some problem with URLs. Currently I'm following this https://docs.phalcon.io/en/latest/reference/tutorial.html tutorial.

My site url: https://localhost/phalconphp

I've created an index page where it shows "Signup here" hyperlink. When I clicked on the link, it goes to "https://localhost/public/signup" instead of "https://localhost/hellophalcon/public/signup"

It happens with every hyperlink, even I created form and again it redirect me to https://localhost/public/signup/register instead of https://localhost/hellophalcon/public/signup/register

Yes I've added an htaccess file on both root and public folder.

Add in you index.php:

  $di = new Phalcon\DI\FactoryDefault();
.....
/**
     * The URL component is used to generate all kind of urls in the application
     */
    $di->set('url', function() use ($config){
        $url = new \Phalcon\Mvc\Url();
        $url->setBaseUri( '/phalconphp/' ); // or $url->setBaseUri( 'https://localhost/phalconphp' );
        return $url;
    });


1.9k

Thanks, works fine.