Jump to content

add or change parametre with seo


UnknownPlayer

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.