I am newbie. How to pass multiple parameters from URL in codeigniter? My function showing ads in a given category
public function show_category($category = false, $subcategory = false, $state = false, $city = false)
{
// Showing ads...
}
I would like my urls to look like this
localhost/show_category/category/subcategory/state/city
But what if one of the parameters is not given? How to make category not mistaken for a city when I pass only two parameters?
localhost/show_category/category/city
Considering it for SEO purpose, I think it would be safe to leave just the category and the subcategory in the url, and leave the rest as GET
variable:
public function show_category($category = false, $subcategory = false)
{
$state = $_GET['state'];
$city = $_GET['city'];
// Showing ads...
}
then you can skip the category
and subcategory
url segment, and send the state
and city
as query string:
localhost/show_category/category/subcategory?state=x&city=y
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.