CodeIgniter Forums
CodeIgniter urls - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: CodeIgniter urls (/showthread.php?tid=23447)



CodeIgniter urls - El Forum - 10-11-2009

[eluser]georgerobbo[/eluser]
Hello,

I would just like some clarification on the CodeIgniter url module. If I developed a simple search form in standard php using the GET method, I would get a standard query string such as
Quote:http://localhost/index.php?id=2
. If I did the same in CodeIgniter, would it automatically rewrite the url to something like
Quote:http://localhost/index.php/welcome/search/2
.


CodeIgniter urls - El Forum - 10-11-2009

[eluser]cahva[/eluser]
Yes. If you used that url, you would have method named search in the Welcome controller with a parameter $id for example. Heres a cup of RTFM Wink


CodeIgniter urls - El Forum - 10-11-2009

[eluser]ggoforth[/eluser]
To answer the second part of your question, no codeigniter will not automatically rewrite your URLS. If you submit a form using GET you are going to get your first URL (?id=2). You need to craft your URLS properly, using POST for form submits, etc... That said, as cahva pointed out, using your second URL codeigniter would properly route you to the Welcome controller and the Search method passing it a variable that in your case, equals 2.