CodeIgniter Forums
Get Original URL after being rewrite by URI Routing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Get Original URL after being rewrite by URI Routing (/showthread.php?tid=26318)



Get Original URL after being rewrite by URI Routing - El Forum - 01-11-2010

[eluser]chandrajatnika[/eluser]
Is that possible for get an original URL after being rewrite by uri routing?
this is my uri routing code (on application/config/routes.php) :
Code:
$route['(sell|buy)/(:num)/(:any).html'] = 'adlist/index/?adType=$1&adCategory;=$2';
I use URI routing only for SEO purpose, and I don't want to change a lot of program logic by doing this.
If I receive an original URL, nothing will happen but when I call uri_string() function, I receive 'fake' URL 'sell/1/Car.html'.
Can I get an original URL like 'adlist/index/?adType=sell&adCategory=1' ??

Thanks for your answers, It will help me a lot.


Get Original URL after being rewrite by URI Routing - El Forum - 01-11-2010

[eluser]Flemming[/eluser]
Hi,

I'm not sure, because I've never tried it, but the documentation suggests you CAN access the original URI ...

http://ellislab.com/codeigniter/user-guide/libraries/uri.html

for example, see '$this->uri->rsegment(n)'

please let me know if you succeed!


Get Original URL after being rewrite by URI Routing - El Forum - 01-11-2010

[eluser]chandrajatnika[/eluser]
thank you, it help me a lot. I've succeed to get an original controller name and function.
but It will not help you get original query string, only uri_string.

anyway, thanks a lot!


Get Original URL after being rewrite by URI Routing - El Forum - 01-12-2010

[eluser]Johan André[/eluser]
You can access the router directly too...

$this->router->controller
$this->router->method