Friendly URLs with querystring params for articles and galleries

Extras that have this functionality in MODX usually work as follows:

  • There is a plugin that runs on the event OnPageNotFound
  • In the plugin, the code checks if the beginning of the request URL path matches certain resource-aliases.
  • With $modx->sendForward(...) the request is redirected to the correct resource.

You could write such a plugin yourself. Here is some sample code:

You could use the extra CustomRequest, if you don’t want to code yourself.

Or use a RewriteRule in the .htaccess file (which I personally don’t like as it’s hard to debug).


Also, if you use pdoPage for the paging (part of the pdoTools extra), then I believe there is built-in option for friendly page URLs.