Allowing for both non .html links and strict .html links with friendly urls?

Hi! Have been wrestling with this for a while, hoping someone can help.

I was given an original Modx website (version 0.0.96 or something?) to manage ages ago, upgraded it to 1.0.12 a while ago, and then not too long ago, after lots of hacking and shenanigans with forced php upgrades breaking our site, I finally hunkered down to switch to Modx Revolution. No easy upgrade path of course, so I’ve just rebuilt everything and adapted all of the tags manually to the Revolution format. No biggy, easy enough, lots of great help articles out there. Really like the CMS.

I have had a bear of a time getting Friendly URLs to work though, and it’s weird because they seemed to finally get their act together on their own, after I’d done all of the things (and found some helpful articles here - thanks!) and then just sat on the Refresh URI option, repeatedly, while praying. I had the empty URI column error mentioned in another post that suddenly fixed itself, still don’t know how.

However, I am coming to the conclusion that the general set up of Friendly URLs in Modx Revolution either allows for .html versions of friendly links, OR non.html versions. It doesn’t seem to like both.

I removed the extension from Content > Content Types so that:

would resolve. I then tried to go to:

Which had previously worked before this, and it’s giving a 404 error.

I found a bit of code here for a plugin that should force everything to HTML, but our previous iteration of Modx, while older than dirt, was able to handle this gracefully, and I can’t see anything that accounts for it in the .htaccess file on the old site.

Is there a way to allow for both in Revolution, without forcing things one way or the other?


I don’t think this is possible (out of the box) in MODX Revolution.

You could probably make it work with a custom plugin:
On the event OnPageNotFound, read the request URL (usually the parameter q) and add/remove the “.html” part. Then use $modx->findResource() again and if you get a result back, use $modx->sendForward() to load that resource.

Thank you for answering my question!

I ended up just keeping the extension for .html and forcing everything to go to .html so that the URL without it could still be used :slight_smile:

Appreciate the help!