开发者

CodeIgniter routing problem when using :any

开发者 https://www.devze.com 2023-02-05 07:47 出处:网络
I\'m having issues with routing in code igniter. 开发者_StackOverflow社区I\'ve got the basics working though.

I'm having issues with routing in code igniter. 开发者_StackOverflow社区I've got the basics working though.

$route['user/authorize'] = "user/asdf";

That dummy line is working fine. This isn't:

$route['user/authorize?code=:any'] = "user/asdf";

and especially

$route['user/authorize?code=:any'] = "user/authorize/$1";

I already changed the $config['permitted_uri_chars'] variable to an empty string (allow all).

I've also tried using (:any) with brackets. I've assumed it was a typo in the manual, since (:num) uses brackets as well. To no effect.

I'm out of ideas. Anyone?

BTW the code variable is a Facebook access token and look something like this:

2.TOCElrzcR5MYz_J8O67hWA__.3600.1295467200-17044424246|4FPbz0N-pXqGWYR81PWGPTY06A4

Not sure if it's relevant, my .htacces file:

RewriteEngine on
RewriteCond $1 !^(index\.php|css|images)
RewriteRule ^(.*)$ /website/index.php/$1 [L]


Since the Codeigniter Structure is:

Controller / Method / Params

I assume that :

User/authorize

is your controller/method.

Now,

$route['user/authorize?code=:any'] = "user/asdf";

Should be :

$route['user/authorize/:any'] = "user/asdf";

where

function authorize($code = null) { echo $code; }

will output same as

function authorize(){ $code = $_GET['code']; }

So oldskool php you write : ninja.php?code=something

in CI is third segment.


/user/authorize/TOCElrzcR5MYz_J8O67hWA__.3600.1295467200-17044424246|4FPbz0N-pXqGWYR81PWGPTY06A4

is equal to

ninja.php?code=TOCElrzcR5MYz_J8O67hWA__.3600.1295467200-17044424246|4FPbz0N-pXqGWYR81PWGPTY06A4

as explained on the begining.


I believe you need to add the following lines to your config:

$config['enable_query_strings'] = TRUE;
$config['uri_protocol'] = "QUERY_STRING";

Source


$config['uri_protocol'] = "PATH_INFO";

Leave everything else to the default.

0

精彩评论

暂无评论...
验证码 换一张
取 消