-1

This is the problem I am going through explained below:

1) When I click on TAB say “blog” the URL shows xxxxxx/blog.php

2) When I click on a topic inside a blog say “shopping” the URL shows xxxx/shopping.php

In my first problem, I want to remove the .php extension from the URL and want it to show like this xxxxxx/blog instead of this xxxxxx/blog.php

In my second problem, I not only want to remove the .php extension from the URL but I also want the URL to show the path like this; xxxxx/blog/shopping instead of showing only this xxxx/shopping.php

<?php

include("company_profile/lib/data.config.php");

// if id exists in URL
if (isset($_GET['id']))
{
$page = (int)$_GET['id'];
}
else
{
$page = '';
}

// limit of pages shown
$limit = 5;

// if page is not empty
if($page == '')
{
$page = 1;
$start = 0;
}
else
{
$start=$limit*($page-1);
}

$query = mysqli_query($conn, "SELECT * FROM blog order by id desc LIMIT            $start, $limit");

$tot = mysqli_query($conn, "SELECT * FROM blog");
$total = mysqli_num_rows($tot);
$num_page = ceil($total/$limit);

// function of pagination that showing number of pages
function pagination($page, $num_page)
{
echo'<ul style="list-style-type:none;">';

for($i=1;$i<=$num_page;$i++)
{
if($i==$page)
{
echo'<li class="pagination-button">'.$i.'</li>';
}
else
{
// <a href="http://example.com/blog/?id='.$i.'">  this is IMPORTANT your url to blog posts
echo'<li class="pagination-button"><a href="http://localhost/soft/arif.php?    id='.$i.'">'.$i.'</a></li>';
}
}

echo'</ul>';
}


?>
Cœur
  • 37,241
  • 25
  • 195
  • 267
arif khan
  • 23
  • 7

1 Answers1

0
RewriteEngine  on
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]
D. Pachauri
  • 244
  • 2
  • 8