PHP + Htaccess, I'm lost for ideas

Hey, I’ve got a forum script named TinyBB(.net), and yesterday I started working on a multi-forum script for it, so we can allow users to create a free forum of their own easily.

Today I ran into my first obstacle that is impossible for me to think of a way around due to my tiredness and confusion.

My htaccess file which controls what I’m doing is this

RewriteRule ^([a-zA-Z0-9_-]+)$  hostedforums/index.php?forum=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ hostedforums/index.php?forum=$1

When you visit it masks the url of

Now I’ve hit a brick wall, since this is what is needed to browse pages. ect

But since this is already doing ?forum=myforum, it cannot do ?page
if you follow.

So I’m looking for a way around this, sorry if you don’t quite understand.

This may not be quite right but I seem to remember doing something like:

RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)$ hostedforums/index.php?forum=$1&page=$2 [L]
RewriteRule ^([a-zA-Z0-9_-]+)$ hostedforums/index.php?forum=$1 [L]

so it catches the directory/page first and just directory second

Thanks for your response, however! Just 2 minutes ago I received a response from a forum I don’t usually ask questions on, they suggested using [L] first and it was correct, however [QSA] was required to make it work fully.

None the less I appreciate your response.