Create segment post URL in Codeigniter


I want to be able to generate a URL that takes form values on post and builds the post URL location,

So taking the post URL that is set as controller search_controller/method/var1/val1/var2/val2/var3/val3 etc etc

so location/britain/data/210412/number/4 etc

This is being done for deep linking linking purposes, so it has to have a URL where this data can be saved and appear so users can bookmark their searches.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Matthew KellyCommented:
I am assuming you are hosting on Apache? You will need to use mod_rewrite to do this:

You will need to do two things:
 1. Set your form so when it posts it makes the url and redirects the user there
 2. Set Apache to parse out the url and translate it into a search page the PHP understands

Here is a lengthy description of it in work:

They below may need more tweaking, but should get you in the right direction.

// page 1
$url = $_POST['search_controller']."/".$_POST['method']."/".$_POST['var1']."/".$_POST['val1']."/".$_POST['var2']."/".$_POST['val2']."/"
header( 'Location: '.$url ) ;
<form method="post">
<input type="text" name="search_controller" value="location" />
<input type="text" name="method" value="britain" />
<input type="text" name="var1" value="data" />
<input type="text" name="val1" value="210412" />
<input type="text" name="var1" value="number" />
<input type="text" name="val1" value="4" />

// mod_rewrite
RewriteRule ^([A-Za-z0-9]+)/?([A-Za-z0-9]*)/?([A-Za-z0-9]*)/?([A-Za-z0-9]*)/?([A-Za-z0-9]*)/?([A-Za-z0-9]*)$ search.php?controller=$1&method=$2&var1=$3&val1=$4&var2=$5&val2=$6

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gegaboneAuthor Commented:
Thanks for this
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.