views:

21

answers:

1

I've been using mod_rewrite in my htaccess file to rewrite my urls and I've run into a problem when doing pagination.

Here's the url for my page: http://domain.com/concerts/features/folk-roots?page=2

htaccess file:

RewriteRule ^features/([^/]*)?page=([0-9]*)$ featureCat.php?cat=$1&page=$2 [NC,L]

It works fine without the page query, but if I want to change pages I can't figure out how to write the regular expression to grab the page #.

Any ideas would be appreciated!

A: 

You need to use RewriteCond immediately before the RewriteRule to get access to the query string:

RewriteCond %{QUERY_STRING} ^page=([0-9]*)$
RewriteRule ^features/([^/]*)$ featureCat.php?cat=$1&page=%1 [NC,L]
sunetos
Thanks sunetos that got it working!
Paul