Files

Using another gateway file name

gourmet fare

Renaming index.php

You can share your web root with another application that also uses an index.php file - from a Slack conversation.

mac_conin asked...

I need some input on how to combine modx and a magento store. I dont want to have store options in the modx pages and vice versa. Its more the aproach of how to set up both systems sharing the same root directory.

The Solution:

opengeek says...

you can configure the modx gateway to another file under Gateway --> 'request_controller'.

What's the Story?

In its System Settings, MODX allows you to configure how MODX is invoked in the Gateway section, and the request_controller setting can be changed from the default index.php, so you can simply rename index.php to something like modx.php and change the system setting.

This means that to use Friendly URLs the web server's rewrite rules would have to be modified to accommodate the change and be able to invoke both the other system's index.php and modx.php as required.

opengeek goes on to describe one configuration he uses involving nginx rewrite rules and a slim app:

       location /api {
            try_files $uri $uri/ /slimapp/index.php?$args;
        }
        location / {
            try_files $uri $uri/ @modx-rewrite;
        }
        location @modx-rewrite {
            rewrite ^/(.*)$ /index.php?q=$1 last;
        }
In that example, I have uri's that begin with /api going to a slim app and everything else from the root handled by modx. You could get more complex with regex matches, but you need some pattern or list of paths to route to one or the other.