Chunks won't save with both "link" & "href" in them

When have “link” and “href” in a chunk, after hitting “Save” the changes are gone.

I see the save progress bar pop up momentarily, but then the changes are gone.

I can add and save this:

<link rel="preconnect">

And this:

<a href="">Link</a>

But if I save this, the changes aren’t saved (using real URLs):

<link rel="preconnect" href="">

I tried creating a TV to put the code into and then reference it through a getResouceField call, but the resource hangs on save if I try to add the links.

I can add “link” tags to templates without a problem, so that is my workaround for now, but it would be better to be able to use a chunk.

I have over 40 installations of MODX and havent experienced this before. If anyone has any clues as to why this is happening would be much appreciated.

Server info:
MODX 2.8.3
MySQL 8.0.26
PHP 7.4.23
Perl 5.26.3
Apache 2.4.51

Sounds like mod_security on the server, or an in-between proxy like Cloudflare, is blocking the requests based on the posted content. Check your server logs, or contact your host for help disabling that/adjusting the rules.

Thanks, Mark. I’ll ask them if anything has changed on the server.

I have this problem with a host I regularly use in Australia. They won’t tell me what rules they need to disable to get it working (so I’m not armed with that information), but there’s like 5-6 rules in their standard mod_security setup they need to disarm for me every time I add a MODX site to their servers.

I’ve been in contact with my server provider (who are always excellent with support) and thay have run various checks and ran a repair on the database etc. but to no avail.

I have investigated futher and found the the same issue occurs with my other MODX installations too, both 2.8.3 and 2.7.x versions, so figure the issue is outside of MODX.

Also, there has recently been a server replacement/upgrade, including PHP version, so have asked them to look into security changes that may have been part of this.

Thanks for this, Josh much appreciated. I’ll pass this on to my server support people and hopefully they’ll take a closer look and be able to identify the rules they need to disable.

There’s no reason at all for them to even look at repairing the database unless there’s an error in the MODX error log that it can’t save the chunk. This really sounds like incompetence on their part to me.

Just to make sure…

You mean after saving and refreshing, right? I.e., the save did not actually take and when you refresh the view it’s gone. Or are you suggesting it actually immediately disappears when you hit save?

If you place the exact same content that you cannot save in a chunk into a template, does that work?

They’ve fixed it. As Mark and Josh said (thank you both), it was a mod_security issue, they changed the relevant rules and it all works fine now.

For others experiencing this issue, mod_security is a security module in Apache where, for example to prevent code injection attacks, certain lines of code can be disallowed. Rules are set in mod_security as to what can and can’t be used which can include adding lines to a database that want to access an external server in a certain way.

Unfortunately, I don’t know what the specific rules are, but your server support people should be able to help with this should you need it.

I’ll change the title of this thread so that others experinecing this issue can find this thread more easily.

Thanks for the input!

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”.