Case Case - 3 days ago 4x
PHP Question

Re write rule refuses to function pagination

I am trying to get my url for my pagination to display as follows

as of now it shows

I have tried the re write below. don't from fr write generator but it does not work


RewriteEngine on
RewriteRule ^p/([^/]*)$ members.php?page=$1 [L]


$number_list = array();
for ($i = 1; $i <= $count; $i ++) {

if ($i == $page) {

echo "<li><a class='active' href='members.php?page={$i}'>{$i}</a></li>";

} else {

echo "<li><a href='members.php?page={$i}'>{$i}</a></li>";


You need to separate between the code you output to the user (using PHP) and mod_rewrite (which translate the pretty-URLs you have to the actual URLs with the variables your PHP code handles).

Lets say you want to write a link to Your php code should look like this:

$i = 1;
echo "<li><a href='members/p{$i}'>{$i}</a></li>";

Now - when someone enter the page members/p1 - you want your PHP code to think that this someone actually entered users.php?page=1 (it's much easier because this way you have the variable $_GET['page'] you can use.

So, to sum it up: 1. In your PHP code - you generate "pretty" links. 2. In your .htaccess file you tell the server to "think" that when it gets a request to ^members/([^/][0-9]*)$ it should treat it as users.php?page=$1