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

.htaccess Settings

I have a Phalcn site for which I am setting up three entry points.

/.htaccess
/index.php
/public
/dashboard
/api

The idea being that apache .htaccess handles sending all requests to /public via the following:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^$ public/     [L]
    RewriteRule (.*) public/$1 [L]
</IfModule>

I would like to account for the dashboard and api directories similarly...without clobbering the /public settings...

Is there any boilerplate .htaccess for this?

Many thanks!!



10.9k

I would just send everything to index.php as normal and employ Phalcon's routing to acheive the desired results.

https://docs.phalcon.io/en/latest/reference/routing.html

I see what you are saying...for the API urls that will work. I think the dashboard urls is the real trick right now. I wanted to keep it on the same directory level as the public folder in order to avoid nesting it under public.



10.9k

You may then want to consider using modules with namespaces https://docs.phalcon.io/en/latest/reference/applications.html#multi-module in your case.

Your structure could then be something like:

app/
    components/
    config/
        config.php
        ...
        ...
        routes.php << Look at the links example but you will be setting routes for each module and declaring defaults
    lib/
    models/
    modules/
        dashboard/
            controllers/
            views/
            Module.php
        api/
            controllers/
            views/
            Module.php   << This is where the magic happens see the link
public/
vendor/

Thanks Andy, that is very close to what I have. I guess if I were to say the question a different way...

Where would the most likely place be for ex a bower_components directory, CSS dir. etc...

I have all of this under /public for the public facing UI...but wanted to avoid the /dashboard under public...



10.9k

What does "Dashboard" contain?

edited May '15

It would contain a bootstrap/Angular admin area template that I will wire up to Phalcon. So, images/css/JS. The HTML would go in a layouts folder for each module...so ex: dashboard.phtml would be under /apps/modules/backend/layouts/ and populated with views under the backend area



7.3k
Accepted
answer

Final resolution: exclude the dashboard directory by using this rewrite rule before all others:

RewriteRule ^(dashboard)($|/) - [L]