Best Practice for Installing Mautic in a Subfolder

Hello,

I have successfully set up Mautic in a subfolder.

Typically, Mautic is installed in the root domain, but I decided to keep the root domain for my website and install Mautic in a distinct subfolder.

To accomplish this, I adjusted the .htaccess file by prepending “XXX” to the path.
<If “%{REQUEST_URI} =~ m#^/XXX/(index|index_dev|upgrade/upgrade).php#”>

This approach worked effectively, but with each Mautic update, the .htaccess file gets reset. As a result, I need to reapply the changes after every update.

Is there a more effective method for handling this?

… copy the htaccess file to the parent directory so it doesnt get overwritten?

The system should apply HTACCESS instructions in inheritance order, IIRC.

1 Like

Hi everyone,

If you have similar requirements to mine, here are a couple of solutions I’ve found that worked:

  1. Install Mautic on a Subdomain: This is a clean solution that avoids conflicts and is easier to manage.

  2. Add Custom Directives in the Virtual Host Configuration.

To prevent custom directives from being overridden during Mautic upgrades, add them directly to the Apache virtual host configuration file for your domain.

In my case, my root domain is www.primeogroup.com, and the configuration file is located at:
/etc/httpd/sites-available/www.primeogroup.com.conf

I added the following directives:

<Directory /var/www/html/primeogroup.com/MySubfolder>
    <IfModule authz_core_module>
        <If "%{REQUEST_URI} =~ m#^/MySubfolder/(index|index_dev|upgrade/upgrade)\.php#">
            Require all granted
        </If>
    </IfModule>
</Directory>

This ensures that access is properly controlled for specific files and that these settings are not overridden by future Mautic updates.

PS: This solution is inspired by @m_hutley

Hope this helps!