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

Redirect to custom page

Hello,

how can i redirect to a custom page.

For example:

A user calls https://www.mysite.com, but my home page is https://www.mysite.com/index. Do i have to do it in my .htaccess? Or in my Controller?.

Rgds



85.5k

its best in your nginx/apache configs if its that simple redirect.

but in controller is


$this->response->redirect("/index");

keep in mind if you using php for that redirect the whole application boots, while the other way around nothing happens :-)



59.9k
edited Jul '18

Hello Izo, thx :-)

How can i config the apache? I am using Vokuro and i have 2 .htaccess, one in root and one in public/. It is not really clear for me.

Rgds



59.9k
Accepted
answer

Yes that is clear, but i have not known it which .htaccess i have to extend it. But after some tries i did it :-)

In public/.htaccess i insert this line:

 DirectoryIndex /index

Complete:

AddDefaultCharset UTF-8

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
    DirectoryIndex /index
</IfModule>

Is that ok?

Rgds Stefan