Jump to content

PHP Link


suzie

Recommended Posts

Dear , In our website to go from page to page or to open an article we use the following Permalink:/content.php?priority=1&table=eco&type=eco&day=Friis there a way to change the format of this link to:for ex:/content.php?priority=1/table=eco/type=eco/day=Frior/content.php?/1/eco/eco/Frior any other format, but my goal is to get rid from th "&"because if i want to tweet the article, twitter does not read the "&", the link will be cutted off..any Suggestion please to have a good and secure permalink,thanks a lot

Link to comment
Share on other sites

Have you tried urlencoding the & character? That might cause other problems. I'm not sure.If you are allowed to use a .htaccess file, you could also try URL-rewriting.Or more simply, you could access your query string directly and parse it yourself. You can find the string here:

$_SERVER['QUERY_STRING'];

(Try var_dumping it just to make sure.) Then you'll need to split the data twice:

if (!empty($_SERVER['QUERY_STRING']) ) {   $q = $_SERVER['QUERY_STRING'];   $pairs = explode ('/', $q);   $len = count($pairs);   for ($i = 0; $i < $len; ++$i) {	  list($a, $b) = explode('=', $pairs[$i]);	  $_GET[$a] = $b;   }}

Now, your $_GET array should function as you normally expect. (And, yes, you can make changes to your $_GET array.)This is the way we used to handle query strings before languages like PHP automated the process. If you ever try this with form data, you'll need to use htmlspecialchars and urldecode on $a and $b before you can use them. That would change the above like this:

	  list($a, $b) = explode('=', $pairs[$i]);	  $a = htmlspecialchars(urldecode($a) );	  $b = htmlspecialchars(urldecode($b) );	  $_GET[$a] = $b;

I should add that the / character of course has special meaning. If this doesn't work out, you might try another character as your pair delimiter.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...