App’s viewport can be placed in several possible contexts, based on the type of the application:

URL Form

App’s primary viewport:[eshop/<eshopId>[/project/<projectId>]]

App’s widget viewport:[eshop/<eshopId>[/project/<projectId>]]


App for eshops

MyEshopsApp is of type eshop, all these URLs are valid:

App for projects

MyProjectsApp is of type project, these URLs are valid:

Behaviour of project app without having project ID specified in its URL is undefined.

App for users

MyUsersApp is of type user, all these URLs are valid:

We know PHP is not suited to handle this style of routing - not without an additional code, some framework or an external library parsing these pretty-URLs. Because we don’t want to force developers to have to use third-party libraries by default, an additional option is planned to have the routing in a form of GET parameters, which will better suit the way of how pure PHP works.

Front controller & .htaccess

Because the only currently supported routing system follows the pretty-URL style, you’ll most definitely want to use a front controller pattern with .htaccess in the app’s public root handling the collection of requests.

Below is the configuration you can use in your app’s /www/.htaccess file to handle pointing all requests to the a single /www/index.php directory:

RewriteEngine On

# Build Mergado App Cloud rewrite base URL.
SetEnvIfNoCase Request_URI (/apps/.+?/) MERGADO_APPCLOUD_REWRITE_BASE=$1

# Redirect trailing slashes if not a directory.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ %{env:MERGADO_APPCLOUD_REWRITE_BASE}$1 [L,R=301]

# Handle front controller.
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ %{env:MERGADO_APPCLOUD_REWRITE_BASE}index.php [L]