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.. Link to comment https://forums.phpfreaks.com/topic/249048-add-or-change-parametre-with-seo/ 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; Link to comment https://forums.phpfreaks.com/topic/249048-add-or-change-parametre-with-seo/#findComment-1279039 Share on other sites More sharing options...
UnknownPlayer Posted October 13, 2011 Author Share Posted October 13, 2011 Thanks.. Link to comment https://forums.phpfreaks.com/topic/249048-add-or-change-parametre-with-seo/#findComment-1279119 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.