Forked from sepiariver/NormalizeUriSuffix.plugin.php
Created
December 21, 2017 12:17
-
-
Save Burick/e2141b4f12cffdb66589829e0b9b7536 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