It seems the “#hashtags” need to correlate to the actual pages already defined with a URL link.
So I would define your $keywords
as an array with #hash
as the KEY and the URL
as the VALUE. Something like this.
$keywords = array('keyword1' => 'pagekeyword1.php', 'keyword2' => 'pagekeyword2.php', 'keyword3' => 'pagekeyword3.php');
Then your links would use both the HASH and the URL so they become links to your actual pages.
//Then your links would use both the HASH and the URL
echo '<p class="flexcenter">'."\r";
foreach ($keywords as $hash => $url):
echo '<span><a href="'.$url.'">#'.$hash.'</a></span>'."\r";
endforeach;
echo '</p>'."\r"
This code results to:
<p class="flexcenter">
<span><a href="pagekeyword1.php">#keyword1</a></span>
<span><a href="pagekeyword2.php">#keyword2</a></span>
<span><a href="pagekeyword3.php">#keyword3</a></span>
</p>
Displayed as:
#keyword1 #keyword2 #keyword3
Now if all your pages already have this keyword list and they are all pointing to hashtag.php
, what does hashtag.php
do or have as far as coding? If you don’t have the page or it isn’t doing anything, then make a page which will redirect the user to the selected page.
Start by making the keyword array that defines all URL pages with the HASH TAG keys.
$keywords = array('keyword1' => 'pagekeyword1.php', 'keyword2' => 'pagekeyword2.php', 'keyword3' => 'pagekeyword3.php', 'keyword4' => 'pagekeyword4.php', 'keyword5' => 'pagekeyword5.php');
//etc
You would then be looking for Request Method GET and not empty. Then define the URL based on if $_GET['tag']
is a KEY in the $keywords
array. If it is a KEY in the array use the array[key]
=>
value, i.e. $keywords[$_GET['tag']]
to get the URL value and use a header()
tag to redirect the user to the webpage or send them to a default page. something like this.
<?php
$keywords = array('keyword1' => 'pagekeyword1.php', 'keyword2' => 'pagekeyword2.php', 'keyword3' => 'pagekeyword3.php', 'keyword4' => 'pagekeyword4.php', 'keyword5' => 'pagekeyword5.php');
if($_SERVER["REQUEST_METHOD"] == "GET" && !empty($_GET['tag'])):
$url = (!empty($_GET['tag']) && array_key_exists($_GET['tag'],$keywords) ? $keywords[$_GET['tag']] : 'defaulturl.php');
header("location: ".$url);
exit;
endif;
?>