Last active
December 21, 2017 12:17
-
-
Save sepiariver/fa524dd5480ffe1f0a59 to your computer and use it in GitHub Desktop.
Plugin to fix trailing slash inconsistencies in MODX Resource URIs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Steps to implement | |
* 1. Set HTML content-type default suffix to '/' | |
* 2. Ensure Resources have isFolder = 1 as default | |
* 3. If you still have issues with Resources being routed to the URI without a trailing slash, | |
* create this Plugin and enable it 'OnWebPageInit'. | |
**/ | |
if ($modx->event->name !== 'OnWebPageInit') return; | |
if (substr($_SERVER['REQUEST_URI'], -1) !== '/') $modx->sendRedirect($_SERVER['REQUEST_URI'] . '/', array( | |
'responseCode' => 'HTTP/1.1 301 Moved Permanently')); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment