@@ -43,9 +43,8 @@ public function handleRequest() {
43
43
asort ($ this ->tags );
44
44
45
45
if ($ this ->pieces [count ($ this ->pieces ) - 1 ] != '' ) {
46
- $ this ->modx ->sendRedirect (MODX_SITE_URL . implode ('/ ' , $ this ->pieces ) . '/ ' , array ('responseCode ' => ' HTTP/1.1 301 Moved Permanently ' ));
46
+ $ this ->modx ->sendRedirect (MODX_SITE_URL . implode ('/ ' , $ this ->pieces ) . '/ ' , array ('responseCode ' => $ _SERVER [ ' SERVER_PROTOCOL ' ] . ' 301 Moved Permanently ' ));
47
47
}
48
-
49
48
if (count ($ this ->pieces ) == 0 || (count ($ this ->pieces ) == 1 && $ this ->pieces [0 ] == '' )) return false ;
50
49
51
50
$ this ->processRequest ();
@@ -77,8 +76,25 @@ private function processRequest() {
77
76
$ q = $ siteStart ->alias ;
78
77
}
79
78
80
- $ _REQUEST [$ this ->modx ->getOption ('request_param_alias ' , null , 'q ' )] = $ q ;
81
-
79
+ $ containerSuffix = trim ($ this ->modx ->getOption ('container_suffix ' , null , '' ));
80
+ $ found = $ this ->modx ->findResource ($ q );
81
+
82
+ if ($ found === false && !empty ($ containerSuffix )) {
83
+ $ suffixLen = strlen ($ containerSuffix );
84
+ $ identifierLen = strlen ($ q );
85
+ if (substr ($ q , $ identifierLen - $ suffixLen ) === $ containerSuffix ) {
86
+ $ identifier = substr ($ q , 0 , $ identifierLen - $ suffixLen );
87
+ $ found = $ this ->modx ->findResource ($ identifier );
88
+ } else {
89
+ $ identifier = "{$ q }{$ containerSuffix }" ;
90
+ $ found = $ this ->modx ->findResource ($ identifier );
91
+ }
92
+ }
93
+
94
+ if ($ found ) {
95
+ $ this ->modx ->sendForward ($ found );
96
+ }
97
+
82
98
return true ;
83
99
}
84
100
}
0 commit comments