Sorry for my english.
I am developing a transport package for modx revolution. My package adds some resources with dynamic content, that depends on some GET parameters. I started working with MODx revolution 2.0. I used to add rewrite rules to my htaccess file to get custom friendly urls for my package-specific urls (I'm using apache server). In revolution 2.0, my htaccess rules were compatible with revolution's ones. However, in the last version (2.2.2), they produce a 301 redirection to the cannonical revolution's url.
An example:
I have a resource with the "Freeze URI" setting active, and this URI:
en/details
In this resource, there is a snippet that uses a GET variable: $_GET['location'], so I add a rule in my htacces that transforms:
en/details/location/madrid
into:
en/details?location=madrid
When I open "en/details/location/madrid" in my browser, it gets a 301 redirect to "en/details?location=madrid".
I have found that the cause of this redirection is a modification in the revolution's modrequest.class.php, method _cleanResourceIdentifier, that was comitted in 2012-01-13 to github. The current code is:
$requestUri = $_SERVER['REQUEST_URI'];
$qsPos = strpos($requestUri, '?');
if ($qsPos !== false) $requestUri = substr($requestUri, 0, $qsPos);
$fullId = $this->modx->getOption('base_url', null, MODX_BASE_URL) . $identifier;
$requestUri = urldecode($requestUri);
if ($fullId !== $requestUri && strpos($requestUri, $fullId) !== 0) {
$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'));
}
$this->modx->resourceMethod = 'alias';
Since $_SERVER['REQUEST_URI'] gets the uri before the apache's rewritting, this produces a redirection.
I have found a partial solution: adding a [P] flag (proxy) to my rewritting rules. However, I don't like this solution, because I want to use this configuration in servers that does not have mod_proxy installed.
My question: ¿is there a way to use custom-friendly-urls and avoid this 301 redirection?
Thank you.
[ed. note: asantos last edited this post 14 years, 4 months ago.]