Using .htaccess for Mautic in a Subfolder Installation

Mautic, a powerful marketing automation tool, can be installed in different configurations. One common method is installing Mautic in a subfolder of your main domain (e.g., mydomain.com/mautic). If you’ve chosen this setup, tweaking your .htaccess file is crucial to ensure everything runs smoothly.

This guide explains how to apply the necessary .htaccess adjustments, addressing common errors and ensuring compatibility with both Apache 2.4 and earlier versions.

Installation Options for Mautic

You can install Mautic in two main ways:

  1. Subdomain Installation: e.g., mautic.mydomain.com
  2. Subfolder Installation: e.g., mydomain.com/mautic

If you’re using option 2 (subfolder installation), the following .htaccess tweak is essential to prevent errors and ensure proper functionality.

Why This Adjustment is Necessary

Installing Mautic in a subfolder can lead to issues due to the default .htaccess configuration, especially with Apache servers. A specific modification is required to inform the server about the folder where Mautic is installed.

Preparing for the Update

Before making changes:

How to Apply the .htaccess Tweak

1. Locate the Relevant Lines

Open your Mautic .htaccess file and find the following line:

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

2. Modify the Code

If Mautic is installed in a subfolder (e.g., /mautic/), update the line to include the folder name. For example:

<If "%{REQUEST_URI} =~ m#^/mautic/(index|index_dev|upgrade/upgrade)\.php#">

Replace /mautic/ with the name of your actual folder if it’s different.

Compatibility with Apache Versions

This tweak works for both:

  • Apache 2.4 and later
  • Earlier Apache versions (pre-2.4)

You’ll find two instances of the line in your .htaccess file. Ensure both are updated to include your Mautic subfolder path.

Next Steps

After updating your .htaccess:

  1. Save the file and upload it to the root of your Mautic installation.
  2. Test your Mautic installation to confirm the changes have resolved any issues.
  3. For additional troubleshooting or complex setups, refer to the GitHub thread for further insights and community support.

Further notes...

Adjusting your .htaccess file is a simple but vital step when installing Mautic in a subfolder. By following these steps, you can ensure a smooth and error-free setup.

If you encounter any challenges or have unique requirements, leave a comment on the GitHub thread or seek advice from the Mautic community.