Categories, Sub Categories and Pagination

New to mod_rewrite? This is a good place to start.

Categories, Sub Categories and Pagination

Postby sezgin » Fri Aug 28, 2009 1:18 pm

Hello,

I want to make a category path with pagination. URL's would be as followed;

All paths should work with or without trailing slash (if possible)

/category/entertainment-and-music/
/category/entertainment-and-music/music/ (represents "music" category under "entertainment and music")
/category/entertainment-and-music/5/ (represents 5th page for "ent. and music")
/category/entertainment-and-music/music/5/ (represents 5th page for "ent. and music/music")


I tried something like that but doesn't work

Code: Select all
RewriteRule ^category/(.*)/? /category.php?slug=$1&page=1
RewriteRule ^category/(.*)/(.*)/? /category.php?slug=$1&page=$2


How can I do something flexible like that?

Thanks in advance...
sezgin
 
Posts: 2
Joined: Fri Aug 28, 2009 1:16 pm

Postby richardk » Sat Aug 29, 2009 2:39 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^category/(.+)/([0-9]+)/?$ /category.php?slug=$1&page=$2 [QSA,L]
RewriteRule ^category/(.+)/?$          /category.php?slug=$1&page=1  [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby sezgin » Sat Aug 29, 2009 3:23 pm

Works very good, thank you very much :)
sezgin
 
Posts: 2
Joined: Fri Aug 28, 2009 1:16 pm


Return to Beginner's Corner

Who is online

Users browsing this forum: No registered users and 19 guests

cron