Welcome Guest, Not a member yet? Register   Sign In
Nice looking Query Strings?
#1

[eluser]jabberjab[/eluser]
Hi there.

I've enabled Query Strings and I'm trying to figure out how to take input this way;

Quote:www.someurl.com/user/add?title=A Title&url=http://www.someurl.com

I am using .htaccess to get rid of index.php, but I've tried and found that I can accomplish sending a query string in this manner:
Quote:www.someurl.com/index.php?c=user&m=add&title=A title&url=http://www.someurl.com

but I'd really like to use the nice URL made by the first example Smile
Any idea on how to accomplish this?

I was guessing it's possible to achieve this with routing, and I tried

$route['user/add?:any'] = ... but I am guessing either the route is wrong or I just don't know how to point it to the index with a trailing query string
#2

[eluser]xwero[/eluser]
the key her is to set the uri_protocol to path_info/orig_path_info/request_uri. This hides the query string for CI so you don't have to add extra allowed_characters or routing.
#3

[eluser]jabberjab[/eluser]
Hiya. I am unsure what you mean, but I tried setting the uri_protocol to all of the 3 (one at a time) but I still wasn't able to use the strucutre; someurl.com/user/add?title=a title&url=http://someurl.com

Anything I've missed?

Another reason as for why I want to do routing is because I'm localising this to norwegian while keeping the code in English. So I need to be able to first get someurl.com/user/add?title=a title&url=http://someurl.com and then have a route to someurl.com/bruker/legg_til?tittel=a title&url=http://someurl.com

Smile
#4

[eluser]xwero[/eluser]
and what is it that didn't work? do you get a 404 or are you not getting the query string values?
#5

[eluser]jabberjab[/eluser]
I'm getting a 404 with REQUEST_URI and with ORIG_PATH_INFO / PATH_INFO set it's not switching pages appropriately.

I'd really like to keep the structure but I just need one PHP action that can take in input in that form, as I want people to be able to submit via an offsite link for example. I am guessing I could just do the long index.php?c=user&m=add&title=title&url=url.com -- but I'd still like to be able to form my query strings as such; url.com/user/add?title=title&url=url.com
#6

[eluser]xwero[/eluser]
have you set the enabled_query_string to true? maybe that could be the cause of your problems, but i doubt it.

If you want to check out what is wrong with the uri_protocol settings add
Code:
echo $_SERVER['PATH_INFO']. ' = ' . $_SERVER['REQUEST_URI'];
if(isset($_SERVER['ORIG_PATH_INFO']))
{
   echo "\n".$_SERVER['ORIG_PATH_INFO'];
}
Then you will know if any of the keys contain a string or not and which one you should use. If none of the keys contain a string i guess your server is not running apache.




Theme © iAndrew 2016 - Forum software by © MyBB