UnknownPlayer Posted October 13, 2011 Share Posted October 13, 2011 I have function for add or change parametre in utl(GET), but when i use seo url and mu url goes like this: www.example.com/article/2 and when i click on pagination button where is that function for add or change, i get this url: www.example.com/article.php?id=2&page=2 but i need to url be like this: www.example.com/article/2?page=2 What should i change in this function: function add_or_change_parameter($parameter, $value) { $params = array(); $output = "?"; $firproun = true; foreach ($_GET as $key=>$val) { if ($key != $parameter) { if (!$firproun) { $output .= "&"; } else { $firproun = false; } $output .= $key."=".urlencode($val); } } if (!$firproun) { $output .= "&"; } $output .= $parameter."=".urlencode($value); return htmlentities($output); } ? Thanks.. Quote Link to comment Share on other sites More sharing options...
requinix Posted October 13, 2011 Share Posted October 13, 2011 1. Ditch add_or_change_parameter() in favor of using a built-in function. 2. When you change the page number, first remove the id from the parameters array. So $url = "/article/" . $_GET["id"]; $get = $_GET; unset($get["id"]); // don't modify $_GET directly $query = http_build_query($get); if ($query) $url .= "?" . $query; Quote Link to comment Share on other sites More sharing options...
UnknownPlayer Posted October 13, 2011 Author Share Posted October 13, 2011 Thanks.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.