0

I am looking to dynamically re-route urls based on a parameter within the uri segment. For example if I have the following url:

domain.com/account/message/action/view

How could I go about creating a route that checked to see if the uri contained "action" and if so re-route to the value of the function + '_' + value of action?

domain.com/account/message_view

I've been reading through the routes documentation provided by ellislab and am still not quite sure how to go about doing something like this or if it would be better to use server rewrite rule? Any information greatly appreciated!

1 Answer 1

2

You would likely want to use the regular expressions availability in routes. Something along the lines of:

$route['([a-z]+)/action/([a-z]+)'] = "$1_$2";

Of course, that may not be exactly what you are looking for, but it should get you started.

Sign up to request clarification or add additional context in comments.

1 Comment

This appears to be exactly what I was looking for. For some reason it just didn't click when I was going over the documentation. Thanks for pointing this out! The working route that I came up with for this is: $route['([a-z]+)/([a-z]+)/action/(.*)'] = "$1/$2_$3";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.