Question

Ideal Method for Installing Mautic in a Subfolder

Hello,

I’ve successfully managed to install Mautic in a subfolder.

While Mautic is typically set up in the root domain, I chose to keep my root domain for the website and install Mautic in a separate subfolder.

  • Root URL: https://www.primeogroup.com/
  • Subfolder: …/XXX

To achieve this, I modified the .htaccess file by adding “XXX” at the start of the path.

<If “%{REQUEST_URI} =~ m#^/XXX/(index|index_dev|upgrade/upgrade).php#”>

This method has worked well, but each time Mautic is updated, the .htaccess file is overwritten. As a result, I have to redo the changes after every update.

Is there a more efficient way to handle this situation?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

KFSys
Site Moderator
Site Moderator badge
August 30, 2024

Heya @simoabdel,

There are a couple of ways to go about this.

The first one would be to chattr and make the file immutable. No one can make changes to it afterward unless you remove that attribute. You can check this here for more information on the topic :

https://www.digitalocean.com/community/questions/what-are-file-directory-attributes

The second way I can think of is for you to create a script that would be executed on a cron or on a service at certain point of time.

Hi everyone,

If you have similar needs to mine, here are a couple of solutions that worked for me:

  1. Install Mautic on a Subdomain: This approach is clean and helps avoid conflicts, making management easier.

  2. Add Custom Directives in the Virtual Host Configuration:

To ensure that custom directives are preserved during Mautic upgrades, add them directly to your Apache virtual host configuration file.

For my setup with the root domain, the configuration file is located at: /etc/httpd/sites-available/www.primeogroup.com.conf

I included 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>

These directives help control access to specific files and prevent future Mautic updates from overriding these settings.

Hope this helps!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
Animation showing a Droplet being created in the DigitalOcean Cloud console