I want to Create SEO Friendly URLs With Htaccess Mod Rewrite like this:
http://localhost/try/pagination/page/4
but now output showing when we click on next button
http://localhost/try/pagination.php/page/pagination.php/page/2
My php code is :
<?php
//include 'config.php';
define('DB_HOST', 'localhost');
define('DB_NAME', 'wr');
define('DB_USER','root');
define('DB_PASSWORD','');
$con=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD) or die("Failed to connect to MySQL: " . mysql_error());
$db=mysql_select_db(DB_NAME,$con) or die("Failed to connect to MySQL: " . mysql_error());
echo $_GET['page'];
$rowsPerPage = 1;
if(isset($_GET['page']))
{
$pageNum= $_GET['page'];
}
else
$pageNum = 1;
$previousRows =($pageNum - 1) * $rowsPerPage;
$query = "SELECT * FROM articles LIMIT $previousRows, $rowsPerPage";
$result = mysql_query($query) or die('Error couldn\'t get the data').mysql_error();
echo "<table border=1>\n";
echo "<tr><th>ID</th><th>Name</th><th>Password</th><th>Perm</th><th>Email</th>
<th>Date</th></tr>";
while(list($id,$title,$content) = mysql_fetch_array($result))
{
echo "<tr><td>$id</td><td>$title</td><td>$content</td></tr>";
}
echo '</table>';
$query = "SELECT COUNT(title) AS numrows FROM articles";
$result = mysql_query($query) or die('Error, couldn\'t get count title=\"$page\"').mysql_error();
$row = mysql_fetch_assoc($result);
$numrows = $row['numrows'];
$lastPage = ceil($numrows/$rowsPerPage);
echo $lastPage;
$phpself = "pagination.php";
echo $phpself;
if ($pageNum > 1)
{
$page = $pageNum - 1;
$prev = " <a href=\"$phpself?page=$page\" title=\"Page $page\">[Back]</a> ";
$first = " <a href=\"$phpself?page=1\" title=\"Page 1\">[First Page]</a> ";
}
else
{
$prev = ' [Back] ';
$first = ' [First Page] ';
}
if ($pageNum < $lastPage)
{
$page = $pageNum + 1;
$next = " <a href=\"$phpself/page/$page\" title=\"Page $page\">[Next]</a> ";
$last = " <a href=\"$phpself?page=$lastPage\" title=\"Page $lastPage\">[Last Page]</a> ";
}
else
{
$next = ' [Next] ';
$last = ' [Last Page] ';
}
echo $first . $prev . " Showing page <bold>$pageNum</bold> of
<bold>$lastPage</bold> pages " . $next . $last;
?>
.htaccess file code is:
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^pagination/page/([0-9]+)\.html$ pagination.php?page=$1
Next requirement is if we are pass the two variable
http://localhost/try/pagination/tag/php/page/2
How I can change in Php code and .htaccess
file?