Hi MODXers, it’s been a while! I’m getting back into MODX after a 8 year hiatus, and I’m having an issue: I cannot save a chunk that has <base href="[[!++site_url]]">. I am using the ACE extra, but I’ve just uninstalled it and tested it again, and this still happens, so ACE is not the issue.
Step to reproduce
Create a new chunk.
Add this code in it:
<head>
<title>Welcome</title>
</head>
Save chunk.
Add <base href="[[!++site_url]]"> below the <title> tag.
Save chunk again.
Observed behavior
The text editor freezes, and I have to refresh the page to edit the chunk again. The <base> does not show up. Nothing is in the error log.
Expected behavior
The chunk should save successfully and I should be able to continue editing the chunk.
This is very likely a problem with [mod_security](https://www.inmotionhosting.com/support/security/what-is-modsecurity-and-why-is-it-important/).
It’s probably triggering a security rule set by your host.
You may be able to bypass it by using < for the left bracket, or the host might disable the rule or mod_security itself if you ask. Sometimes you can turn it off yourself in .htaccess with this code:
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
Worst case, you can paste the code into the snippet field of the chunk in the DB.
I forgot how amazing the MODX Community is, and how that’s one of the reasons as to why I love MODX. Thanks for your quick reply @bobray, I went the quick way and updated the modxjg_site_htmlsnippets which worked like a charm.
The only downside is that now I can’t save that chunk if make any changes to it. I even tried adding the code you provided in .htaccess.
It might be possible to create a plugin that would do the save for you when you click save, but it’s kind of overkill for just one chunk and it might not work.
It might be worth filing a support ticket with your host.
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.