CodeIgniter Forums
routing problem - 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: routing problem (/showthread.php?tid=13266)



routing problem - El Forum - 11-16-2008

[eluser]Thorpe Obazee[/eluser]
I need to have a url that either accepts

website.com/index.php/ad/2212

website.com/index.php/ad/2212/

or website.com/index.php/ad/2212/free-computers

I already have a routing like this:

Code:
$route['ad/(\d+)/(:any)'] = "ad/view/$1";

this only works for "website.com/index.php/ad/2212/free-computers" but not for "website.com/index.php/ad/2212" or "website.com/index.php/ad/2212/"


routing problem - El Forum - 11-16-2008

[eluser]Thorpe Obazee[/eluser]
My fix right now is this

Code:
$route['ad/(\d+)'] = "ad/view/$1";
$route['ad/(\d+)/(.*)'] = "ad/view/$1";

I have 2 routes. I am thinking if there's a better way to do this using one route.


routing problem - El Forum - 11-17-2008

[eluser]Pascal Kriete[/eluser]
Does this work for you:
Code:
$route['ad/(\d+)/?.*'] = "ad/view/$1";



routing problem - El Forum - 11-17-2008

[eluser]xwero[/eluser]
Routing an url with more than the needed arguments should raise an error otherwise spiders will fetch duplicate content which reduces your chances having a good page ranking.


routing problem - El Forum - 11-17-2008

[eluser]Pascal Kriete[/eluser]
[quote author="xwero" date="1226943272"]Routing an url with more than the needed arguments should raise an error otherwise spiders will fetch duplicate content which reduces your chances having a good page ranking.[/quote]
Unless it isn't publicly accessible (read: backend), but xwero does make a good point here.