Base (Site) URL problem when sending email to segment

Apologies: I edited this post because I partially fixed my original problem, but I still have one remaining issue with the unsubscribe_text. Please see update in the reply below. Thank you!

Your software
My Mautic version is:4.4.7
My PHP version is:7.4.30
My Database type and version is: mariadb-10.3.35

Your problem
My problem is:
Hi all: new to Mautic, and just trying to get through initial setup and testing. I have Mautic running on a RHEL (Rocky 8) server on a private network behind a public Nginx reverse proxy.

On my private network, I can access the Mautic dashboard like this:

My Nginx reverse proxy and global Site URL setting is configured like:

This seems to work fairly well; for example, on the public side, I can visit and all seems good. However, if I add an image to the landing page, the link on the page looks like this:

and the backend (Mautic) webserver does a 301 redirect to:

In other words, it seems that if I’m calling for the “index.php” file, it rewrites the URL to the wrong BASE URL, not the one set up in the Mautic General Settings. I took a look at the .htaccess file and found that if I edit the RewriteRule on line 37, replacing the %{ENV:BASE} with, the problem is fixed. So, basically wondering if there’s some other setting that I need to update on the Mautic dashboard to fix this the correct way?

The second issue that I’m seeing is somewhat related. I sent a test campaign to see if the {unsubscribe_url} is set correctly to show my Contact Preference Page. Again, I’m seeing the wrong base URL in the unsubscribe_url: I’m seeing this in the email: instead of

Steps I’ve tried to fix the problem:
Manually edited .htaccess file to fix the image loading problem: a hack, but seems to work.
Not sure how to fix the unsubscribe_url problem.

Thanks in advance for your help!

UPDATE: I think I may have fixed the problem regarding the Nginx proxy.

On my nginx proxy, I added the following to my config:

proxy_set_header Host $host;

This ensures that the original host (www.example) is sent to the backend (Mautic) server, which seems like it fixed the issue with the .htaccess file.

UPDATE: I’m not sure what I did, but the subscribe_url problem seems to have gone away. However, still wondering why when an URL containing index.php shows up, it redirects to the wrong base URL, unless I hack the .htaccess file.

UPDATE2: Er… maybe I spoke too soon. Not sure, but maybe the problem didn’t go away.

UPDATE3: There still seems to be a problem, perhaps during cron processing or somehow when an email is sent to a segment. When I view a preview of an email, for example like this:

The links inside the email look correct, for example unsubscribe looks like this: Also, if I send a one-off email using the [Send Example] button, the resulting email has the correct links!

However, if I tell mautic to send out the real email to my test contact, once I get my email on, it reverts back to this form for unsubscribe:

Very frustrating! Could there be something that’s cached? What else could be causing an actual email that’s sent to the test segment to behave differently from the preview?


I think I found a bug in Mautic; at least a way to avoid this issue. As I described above, I set up Mautic on a back end server that gets reverse-proxyed and SSL’d to the public via Nginx.

In my tests, I found that when I log in to Mautic via its private IP like this: and I create an email, it uses the wrong base url for all the links in the email. I.e., it seems to ignore the system configuration base URL setting and goes for whatever I logged into Mautic with. This seems like a bug to me.

When I log in to Mautic through my reverse-proxy,, then It composes emails with the right base URL. This is unfortunate because I was hoping to completely block the admin interface from the general public.

I’d be interested in hearing from more experienced users whether I’ve missed some setting somewhere or whether this is indeed a bug.


I think this is a known issue and will be fixed in 4.4.8

See this PR: Fix segment mails not using site_url [backport to 4.x] by nick-vanpraet · Pull Request #11920 · mautic/mautic · GitHub


I wonder if it also affects the multi domain plugin…