I am trying to create nice URL’s and I think there is something missing here. When I type localhost:8888/publisherid-publishername , I want to be able to generate a dynamic page for the specific publisher that has the id of publisherid
. I hope I can get some help.
Here is my .htaccess file
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^([^-]+)-(.+)$ /publisher.php?publisher_id=$1 [L,QSA] // is this structure correct? I create a thing called publisher_id here, then GET it below.
Here is my publisher.php page
<?php
include('cn/connect.php');
function seola($s)
{
$tr = array('ş', 'Ş', 'ı', 'İ', 'ğ', 'Ğ', 'ü', 'Ü', 'ö', 'Ö', 'Ç', 'ç');
$eng = array('s', 's', 'i', 'i', 'g', 'g', 'u', 'u', 'o', 'o', 'c', 'c');
$s = str_replace($tr, $eng, $s);
$s = strtolower($s);
$s = preg_replace('/&.+?;/', '', $s);
$s = preg_replace('/[^%a-z0-9 _-]/', '', $s);
$s = preg_replace('/\s+/', '-', $s);
$s = preg_replace('|-+|', '-', $s);
$s = trim($s, '-');
return $s;
}
$publisher_id = $_GET['publisher_id']; // I am trying to get the URL's id with this line.
$getir = "SELECT publisher_name, publisher_id from publisher WHERE publisher_id = '$publisher_id'";
$getir_sonuc = $sqli->query($getir);
$getir_satir = $getir_sonuc->fetch_assoc();
$publisher_name = $getir_satir['publisher_name'];
$publisher_id_bitir = $getir_satir['publisher_id'];
echo "<a href='http://localhost:8888/" . $publisher_id_bitir . "-" . seola($publisher_name) . "'>" . $publisher_name . "</a>";
It’s okay, but when I click on the a link, I go to the localhost:8888/publisherid-publishername page, and it’s blank! Isn’t it supposed to be my publisher.php page?
Where is my error?