.htaccess General Rule for All Pagination

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

+4
source share
2 answers

Change the rewrite rule as follows:

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

A key change is the use of the QSA flag, which will keep the original query string even after adding id=$1 .

+3
source

This is something like

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

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

+1
source

Source: https://habr.com/ru/post/1402649/


All Articles