tags:

views:

353

answers:

1

Hey

I am currently showing results using the following url index.php?id=1 and using .htaccess to rewrite it like cat/sub-cat/ and i am using pagination and the url to the next page is index.php?page=2 etc but i can't seem to get the pagination to work with my .htaccess rewritten url so for example threads/thread-name/ shows the page fine etc but when i click on the next page link i just get the same page, if i use the normal url such as index.php?id=1&page=2 that works fine but i can't seem to get it to work in a nicer fashion

Hope that explains the issue clearly :)

+1  A: 

If I understand your problem correctly, then you need a rewriterule something like this:

RewriteRule ([a-zA-Z_-]+)/([0-9]?) index.php?id=$1&page=$2

Which then directs /mycoolpage/2 to index.php?id=mycoolpage&page=2 etc

And if the last number is not present, then the page query parameter will simply be blank (so you'd assume page=1)

Joel L
Hi thanks a lot for the input, that sounds just like what i want it to do but i really don't know much about .htaccess (yet) so would i put this before my RewriteRule postname/ index.php?id=1 rule ?
David
probably you should replace it David.
yoda
Hi i have just tested this out but will have to change the way i retrieve posts as id in my script is a number not the postname therefore i would have to use a url like /1/ instead of /postname/ for it to work...
David
cracked it - works a treat thanks so much !
David