Module and PrettyURL
Posted: Fri Feb 04, 2011 2:08 pm
I maintain a website for a university department:
http://www.control.lth.se
It is powered by cmsms 1.9.2, and most things work as I expect them to, including prettyURLs in general. There is however a specific problem when I want to use prettyURLs in a module I have written. The module is for displaying information from our publication database, and the RegisterRoute statement in the module.php file is
This works in many cases, for example (ugly URL followed by prettyURL):
http://www.control.lth.se/index.php?mac ... eturnid=60
http://www.control.lth.se/Publication/gis10cdc.html
However, in the following case the prettyURL fails:
http://www.control.lth.se/index.php?mac ... eturnid=60
http://www.control.lth.se/Publication/hen+cer10.html
The reason it fails is the '+' character in the last part of the URL. I have found out that when it comes in to the action routine, as the variable $artkey, its value is 'hen cer10' instead of 'hen+cer10'. It does not help to use '%2B' in the URL, it is still converted to a space character.
After all this introduction on to my question: Is there some specification that says that this is the required behavior, or is there some other reason? I have tried to find it in the source, but I don't know my way around well enough. In this particular case I can work around the problem by simply letting the action routine convert space to '+', but it is not a very satisfying solution.
Thanks,
Leif
http://www.control.lth.se
It is powered by cmsms 1.9.2, and most things work as I expect them to, including prettyURLs in general. There is however a specific problem when I want to use prettyURLs in a module I have written. The module is for displaying information from our publication database, and the RegisterRoute statement in the module.php file is
Code: Select all
$this->RegisterRoute('#Publication/(?P<artkey>.+$)#',
array('action'=>'showpublication','returnid'=>'60'));
http://www.control.lth.se/index.php?mac ... eturnid=60
http://www.control.lth.se/Publication/gis10cdc.html
However, in the following case the prettyURL fails:
http://www.control.lth.se/index.php?mac ... eturnid=60
http://www.control.lth.se/Publication/hen+cer10.html
The reason it fails is the '+' character in the last part of the URL. I have found out that when it comes in to the action routine, as the variable $artkey, its value is 'hen cer10' instead of 'hen+cer10'. It does not help to use '%2B' in the URL, it is still converted to a space character.
After all this introduction on to my question: Is there some specification that says that this is the required behavior, or is there some other reason? I have tried to find it in the source, but I don't know my way around well enough. In this particular case I can work around the problem by simply letting the action routine convert space to '+', but it is not a very satisfying solution.
Thanks,
Leif