Welcome Guest, Not a member yet? Register   Sign In
routes help
#1

[eluser]dippy[/eluser]
First off, hello everyone. i am new here.

I need a little help here. i need to have a url with a dash in it for SEO.

I have been going over the documentation and see i can use the routes.php to re route the page.

here is what i got, but its not working.

Code:
$route['solutions/hpprinters'] = "solutions/hp-printers";


i get this error:
"
404 Page Not Found
The page you requested was not found.
"

Even when i go to this url: 'solutions/hpprinters' i get a 404 too? but if i take the route out of the routes.php file i can then see 'solutions/hpprinters' fine.


am i forgetting something here?

i even changed the uri_protocol setting in config.php to REQUEST_URI


Any ideas?

Thanks in advance.
#2

[eluser]Colin Williams[/eluser]
I think you need to reverse it. The $route indeces are the route, the values are the application paths (an application path won't ever have dashes).

Code:
$route['solutions/hp-printers'] = 'solutions/hpprinters';
#3

[eluser]dippy[/eluser]
[quote author="Colin Williams" date="1226401754"]I think you need to reverse it. The $route indeces are the route, the values are the application paths (an application path won't ever have dashes).

Code:
$route['solutions/hp-printers'] = 'solutions/hpprinters';
[/quote]

awesome thank you i will try this.

Thanks!
#4

[eluser]dippy[/eluser]
I am having another routes problem.

i have the following code in my route config file:

Code:
$route['services/:any'] = "services/section";

is there a way to have the below work if the above code is also in the config file?


Code:
$route['services/search/:any'] = "services/search";

it wasnt working it kept bringing me to services/section when i tried to do services/search/19428 ...


this is what i am trying to accomplish.

services/carwash
(services/section)
the above will show the landing page for that specific service.

services/carwash/19428
(services/section/search)
and this will search in the database under section carwash and search for zipcode 19428.


Any help would be great with my route issue!

thanks a bunch!
#5

[eluser]Johan André[/eluser]
should'nt it be (:any) instead of :any?
#6

[eluser]Dam1an[/eluser]
[quote author="Johan André" date="1250123759"]should'nt it be (:any) instead of :any?[/quote]
AFAIK, :any will match the route, but you need the brackets if you want to pass that value into the re-routed route (but can still use the segment(n) and rsegment(n) methods if you don't pass the reroute value into the function)
#7

[eluser]dippy[/eluser]
thanks for the info fellas

i will try the above...
#8

[eluser]Johan André[/eluser]
[quote author="Dam1an" date="1250124238"][quote author="Johan André" date="1250123759"]should'nt it be (:any) instead of :any?[/quote]
AFAIK, :any will match the route, but you need the brackets if you want to pass that value into the re-routed route (but can still use the segment(n) and rsegment(n) methods if you don't pass the reroute value into the function)[/quote]

ahh! i did'nt know that... Smile
#9

[eluser]dippy[/eluser]
I have the following in my routes:
Code:
$route['services/:any'] = "services/section";
so i can goto a url like this: 'services/towing' and the php will pull that sections info into the page view.

and then i also want to have a url like the following: 'services/towing/company-name' - and have that route to another function in the services controller to pull that's company info.

can this be done?

when i tried to do this all i kept getting was the section.

so i added this for a temp. solution.
Code:
$route['search/:any'] = "services/search";

but id like to have it under services/section in the url.

any suggestions?
#10

[eluser]dippy[/eluser]
Any help on this?




Theme © iAndrew 2016 - Forum software by © MyBB