0

I have a search city in my website, my search bar is a option where they can select which city they want to view. but when i search a city in my website, it directs to this url: foobar.com/s/

now i want the url to become like this: foobar.com/s/california

my select options have this format:

<select name='city'>
<option value='california'>California</option>
</select>

how can i make the value of the option be seen in the url?

1 Answer 1

1

You need to first redirect to foobar.com/s/california once user has selected the option from the Dropdown and then do routing to send your URL to respective controller

something like

  $route['s/(:any)'] = "s/your_method_name/$1";
Sign up to request clarification or add additional context in comments.

2 Comments

is there other solution for this? redirecting seems slow since i need to direct user 2 times.
Redirecting is a only solution for changing in a URL, as we can not change the URL without redirecting. Or you have another solution to add # tag foobar.com/s/#california but in this way php script will not be able to get the city name.

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.