Regular Expression For URL Query
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 th开发者_StackOverflow社区e 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!
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]
精彩评论