Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Dynamic subdomains with Phalcon

Does Phalcon support dynamic subdomains with modules? I woud like to create such routing, which depends on subdomain: - route to module: frontend and index/index - route to module: backend and index/index.

In conclusion, I want to have two same routes, but in diffrent modules. Is it possible? I tried to create own routing and dispatcher rules, but it doesn't work. Do You have working example?

edited Oct '15

Assuming you are using Apache web server, modify the .htaccess file inside your public folder (warning: untested):

AddDefaultCharset UTF-8

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f

    RewriteCond %{HTTP_HOST} ^(([^.]*)\.)?backend\.phalcon\.com$ [NC]
    RewriteRule ^(.*)$ index.php?_url=/backend/$1 [QSA,L]

    RewriteCond %{HTTP_HOST} ^(([^.]*)\.)?phalcon\.com$ [NC]
    RewriteRule ^(.*)$ index.php?_url=/frontend/$1 [QSA,L]

Then configure your routing to catch the module name.

It works perfect with some fixes, thanks!