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

How does htrouter work?

The basic tutorial says that you need to put .htrouter.php to the root of your project, also giving the posibility of not using .htacces or configure whichever web server you are using. But I've been trying to make it work without .htaccess or configuring apache, and it doesn't. So what is really the functionality of this file?

I leave it at project's root, so if my project is called work, inside this you can see app folder, public folder and .htrouter.php, and I turn on apache, then go to firefox and enter

https://localhost/phalcon/work/

It will only show the listing of folder and files, unless they have a dot at the beginning of its name. When created with phalcon-devtools, if i remove the .htaccess file, it will not work showing the content of the index.html, that says:

Mod-Rewrite is not enabled Please enable rewrite module on your web server to continue

So, what is this all about? Is the tutorial out of date? Am I missing something here? Somekind of configuration to make the .htrouter.php file work?

Thanks fo help



77.7k
Accepted
answer

In the examples, .htrouter.php is only used when running PHP's built-in webserver. Apache has no mechanism to use that file.

https://github.com/phalcon/tutorial/blob/master/.htrouter.php

https://docs.phalcon.io/en/latest/webserver-setup#php-built-in

Oh, nice, thank you, I was reading it without going into the side articles. Now I really get it. I had to read a bit more, but you helped me understand it better. I will try to keep up with every single related article so I can manage my way around this framework!

edited Apr '18

Oh, nice, thank you, I was reading it without going into the side articles. Now I really get it. I had to read a bit more, but you helped me understand it better. I will try to keep up with every single related article so I can manage my way around this framework!

It's fine to ask questions here, the docs can be overwhelming in one sit ;]