Welcome Guest, Not a member yet? Register   Sign In
Escape ? in URL
#1

[eluser]Unknown[/eluser]
Hi everybody,

I got a problem, I'm trying to use phpcas in CodeIgniter and I'm struggling with the way phpcas uses tickets with $_GET variables.

After I connected, CAS server redirects me on my page with the kind of URL :
.../index.php/login/auth?ticket=ST-55743-Tj9b7bRHNzPI9fQRPNXHwkDtDfgyVIucKjD-20

Unfortunately, CodeIgniter returns me an error 404 because of the question mark.

I don't have access to CAS server so I'm compelled to deal with this kind of URL.

I tried to add a slash after "auth" in my url so that "?ticket=ST-..." can be considered as a parameter in my url but the question mark remains a problem.

Does anybody know a way to solve my problem?
#2

[eluser]jedd[/eluser]
Hi jerry_ and welcome to the CI forums.

Have you read [url="http://ellislab.com/codeigniter/user-guide/general/urls.html"]this bit of the CI user guide[/url] - it talks about turning query strings back on, so it can handle the ? and & stuff you get from those other legacy apps. Wink
#3

[eluser]jedd[/eluser]
Addenda - just re-read, and might have missed the mark a bit.

You may want to play with [url="http://ellislab.com/codeigniter/user-guide/general/routing.html"]routing[/url] instead. I'm not a routing guru, but what you want to do shouldn't be too tricky.

Perhaps something like (and this is very much untested - I really don't use routes myself)
Code:
$route['login/auth?:any'] = "login/auth/$1";
#4

[eluser]xwero[/eluser]
if you set the uri_protocol to PATH_INFO/ORIG_PATH_INFO/REQUEST_URI the router class will not see the query string.

To get a value from the query string you have to add following to your method
Code:
parse_str($_SERVER['QUERY_STRING'], $_GET);
This is because CI clears the GET global.
#5

[eluser]Colin Williams[/eluser]
Quote:This is because CI clears the GET global.

Only if $config['enable_query_strings'] is set to FALSE. The first time I ran into an issue where I needed $_GET values, I intuitively set it to TRUE and voila.
#6

[eluser]Unknown[/eluser]
Thanks for your answers.

I've finally solve my problem using Jamie Rumbelow's solution here.
#7

[eluser]xwero[/eluser]
Jamie's solution is a weird one i think because first the allow_get_array class variable gets set making the enable_query_strings config setting almost dead and then it sets the uri_protocol so it can't spot the query string, on top of that the question mark gets added to the permitted_uri_chars config setting.

Colin is right the GET global only gets cleared when the enable_query_strings is set to false but setting it to true it makes it possible to reach the same page using two url forms; http://site.com/index.php/controller/method and http://site.com/index.php?c=controller&m=method. if people use both of the forms this will affect the pagerank.




Theme © iAndrew 2016 - Forum software by © MyBB