Vassilis A. Alexiou
Vassilis A. Alexiou

Reputation: 105

.htaccess General Rule for all Pagination

How can I take the page var from http://domain.com/recent?page=2 (the original page is http://domain.com/?id=recent&page=2) with .htaccess? (i need a general rule for all pages) thanx for help

Upvotes: 4

Views: 244

Answers (2)

anubhava
anubhava

Reputation: 785286

Change your rewrite rule to this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^([^/]+)/?$ index.php?id=$1 [L,QSA]

Key change is use of QSA flag which will preserve original query string even after adding id=$1.

Upvotes: 3

NeeL
NeeL

Reputation: 720

It's something like

RewriteRule (.+)?page=([0-9]+) ?id=$1&page=$2

Take a look at regex and examples you can find on google ;)

Upvotes: 1

Related Questions