Welcome Guest, Not a member yet? Register   Sign In
URI segment is not working while "query strings" is working
#1

[eluser]Subekti Pranoto[/eluser]
File "<webroot>\system\application\config\config.php" like this:
==============================================================================
$config['enable_query_strings'] = TRUE;
$config['controller_trigger'] = 'c';
$config['function_trigger'] = 'm';
==============================================================================


File “/<webroot>/system/application/controllers/welcome.php” like this:
==============================================================================
&lt;?php

class Welcome extends Controller {

function Welcome()
{
parent::Controller();
}

function index()
{
$this->load->view('welcome_message');
}

function Test()
{
echo "CI is great";
}

}
?&gt;

==============================================================================

when i point my browser to “http://localhost/index.php/welcome/test”, i get message “The page cannot be found”.

when i point my browser to "http://localhost/index.php?c=welocme&m=test", i get the message "CI is great".

Does anyone have any thoughts on what could be causing this?
#2

[eluser]tonanbarbarian[/eluser]
I have posted something to try in this other thread
http://ellislab.com/forums/viewreply/331415/

Your problem is that you have enable_query_string turned on, and in that case I do not think it will accept the url in the format of http://localhost/index.php/welcome/test, only http://localhost/index.php?c=welocme&m=test
#3

[eluser]Subekti Pranoto[/eluser]
When i do your suggest...

File “<webroot>\system\application\config\config.php” like this:
==============================================================================
$config[’enable_query_strings’] = FALSE;
==============================================================================

when i point my browser to “http://localhost/index.php?c=welocme&m=test”, i get the message “The URI you submitted has disallowed characters”.

Does anyone have any thoughts on what could be causing this?
#4

[eluser]tonanbarbarian[/eluser]
ok i am confused

are you trying to get the url to be
http://localhost/index.php/welcome/test
or
http://localhost/index.php?c=welocme&m=test

I do not think it can allow both

If you want http://localhost/index.php/welcome/test
Code:
$config[’enable_query_strings’] = FALSE;

if you want http://localhost/index.php?c=welocme&m=test
Code:
$config[’enable_query_strings’] = TRUE;
#5

[eluser]Subekti Pranoto[/eluser]
When i do your suggest…

File “<webroot>\system\application\config\config.php” like this:
==============================================================================
$config[’enable_query_strings’] = FALSE;
==============================================================================

when i point my browser to “http://localhost/index.php/welcome/test”, i get message “The page cannot be found”.

when i point my browser to “http://localhost/index.php?c=welocme&m=test”, i get the message “The URI you submitted has disallowed characters”.

i use ms4w (map server for windows) 2.2.3 bundle, apache 2.2.4, php 5.2.1

Does anyone have any thoughts on what could be causing this?
#6

[eluser]tonanbarbarian[/eluser]
have you tried the other options from the other post?

So try each of the following options.
Code:
$config['uri_protocol']    = "PATH_INFO";

Code:
$config['uri_protocol']    = "QUERY_STRING";

Code:
$config['uri_protocol']    = "REQUEST_URI";

Code:
$config['uri_protocol']    = "ORIG_PATH_INFO"
#7

[eluser]Subekti Pranoto[/eluser]
When i do your suggest…

File “<webroot>\system\application\config\config.php” like this:
==============================================================================
$config[’enable_query_strings’] = FALSE;
==============================================================================

with

==============================================================================
$config['uri_protocol'] = "PATH_INFO";
or
$config['uri_protocol'] = "QUERY_STRING";
or
$config['uri_protocol'] = "REQUEST_URI";
or
$config['uri_protocol'] = "ORIG_PATH_INFO"

==============================================================================

when i point my browser to “http://localhost/index.php/welcome/test”, i get message “The page cannot be found”.

when i point my browser to “http://localhost/index.php?c=welocme&m=test”, i get the message “The URI you submitted has disallowed characters”.

i use ms4w (map server for windows) 2.2.3 bundle, apache 2.2.4, php 5.2.1.
it seem that MS4W PHP5 Base Installer v2.2.6 (Sept 18, 2007) is available. (http://www.maptools.org/ms4w/index.phtml...loads.html)

Does anyone have any thoughts on what could be causing this?
#8

[eluser]Subekti Pranoto[/eluser]
Hi tonanbarbarian,

i do upgrade from ms4w 2.2.3 to ms4w 2.2.6. my problem has solved.

File “<webroot>\system\application\config\config.php” like this:
==============================================================================
$config[’enable_query_strings’] = TRUE;
$config[’controller_trigger’] = ‘c’;
$config[’function_trigger’] = ‘m’;
==============================================================================


File “/<webroot>/system/application/controllers/welcome.php” like this:
==============================================================================
&lt;?php

class Welcome extends Controller {

function Welcome()
{
parent::Controller();
}

function index()
{
$this->load->view('welcome_message');
}

function Test()
{
echo "CI is really great";
}

}
?&gt;

==============================================================================

when i point my browser to “http://localhost/index.php/welcome/test”, i get message “CI is really great”.

when i point my browser to “http://localhost/index.php?c=welocme&m=test”, i get the message “CI is really great”.
#9

[eluser]Unknown[/eluser]
If both method can't be supported how can i access a page having some required and option params?

Typically I would put the requided param in the "path" segment and the optional params in the query string part. Something like www.xyz.com/controller/action/req_param1/req_param2?opt_param_name1=opt_param_value1&opt_param_name2=opt_param_value2

Since they are optional params, it's not really possible to have a fix order if we put them in the path. For example in www.xyz.com/controller/action/req_param1/req_param2/opt_param the last segment could be either opt_param_value1 or opt_param_value2.

What would be the way to solve optional params. I do want to use the path style URI.

Thanks much




Theme © iAndrew 2016 - Forum software by © MyBB