I am able to create a unique URL http://site.com/pod.php?id=20
I have had 404 errors when trying different methods through php and htaccess to rewrite the URLs.
I have different fields in the database which I would like to use in order to construct the URL and make it SEO friendly. These fields would be name, location and category. The URL should be like this http://site.com/name/location
Really what I am asking is how do I accomplish this? Examples would be fantastic.
Files I use below:
part of content.php
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
echo "<div class=\"pods\">";
echo "<a href=\"/pod.php?id={$row['id']}\">";
echo "<div class=\"podHeading\">";
echo "{$row['heading']}</a> <br> ";
echo "</div>";
echo "<div class=\"podImage\">";
echo "<img src=\"images/{$row['imageName']}\">";
echo "</div>";
$string = "{$row['text']}";
if(strlen(htmlspecialchars_decode($string)) > 100) {
echo substr(htmlspecialchars_decode($string), 0, 100).'...'.$hyperlink;}
else {
echo htmlspecialchars_decode($string);
}
pod.php:
<?php
$connect = mysql_connect('x', 'x', 'x');
$select_db = mysql_select_db('x');
$id = mysql_real_escape_string($_GET['id']);
$query = 'SELECT * FROM podContent WHERE id = '.$id.' LIMIT 1';
$result = mysql_query($query);
$row = mysql_fetch_array($result);
// Echo page content
echo "<div class=\"podPageContainer\">";
echo "<div class=\"podPageContent\">";
echo "<div class=\"podPageHeading\">";
echo $row['heading'];
echo "</div>\n";
echo "<br/>";
echo $row['text'];
echo "</div>\n";
echo "</div>\n";
echo "<div class=\"pageSidebar\">";
include('ads/sidebarAds.php');
echo "</div>\n";
?>
.htaccess
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.site.com/$1 [R=301,L]
Options +FollowSymlinks
RewriteEngine On
Any help is greatly appreciated, Thank you!