Hi there !
OK I got a dynamic page based on some query parameters, let's say :
http://whatever.com/modx-page.html?product=white-product
http://whatever.com/modx-page.html?product=black-product
http://whatever.com/modx-page.html?product=red-product
Now, I want these URLs to look nicer, for example :
http://whatever.com/modx-page-white-product.html
http://whatever.com/modx-page-black-product.html
http://whatever.com/modx-page-red-product.html
How would you do that ? This is not just a 3 products things, there are 100's of products so this is not something I can do manually within the manager doing tricks or whatever with aliases.
I came with the idea of rewriting with some Apache rules.
Worked great with 2.1.5. Now 2 days ago I upgraded to 2.2.1 and the stuff is broken. Why ? Because of this piece of code in modxrequest.class.php / _cleanResourceIdentifier :
$requestUri = preg_replace('/\?.*/', '', $_SERVER['REQUEST_URI']);
if ($this->modx->getOption('base_url', null, MODX_BASE_URL) . $identifier !== $requestUri) {
$parameters = $this->getParameters();
unset($parameters[$this->modx->getOption('request_param_alias')]);
$url = $this->modx->makeUrl($this->modx->aliasMap[$identifier], '', $parameters, 'full');
$this->modx->sendRedirect($url, array('responseCode' => 'HTTP/1.1 301 Moved Permanently'));
}
Basically it checks if the URL is what it's supposed to be (ie : is modx-page-white-product.html the correct URL ?), if not (that's the case, it should be
http://whatever.com/modx-page.html?product=white-product), a redirect happens. Which make all my efforts to have nice URLs pointless.
Question is, why was this added ? Any developer out there that could point the reason ? If there's a good reason or no developer can answer, can anyone think of an alternative solution to the problem ?
Thanks !