More HtAccess Rewrite Rules

Posted by pws5068 on Stack Overflow See other posts from Stack Overflow or by pws5068
Published on 2010-04-03T20:33:24Z Indexed on 2010/04/03 20:43 UTC
Read the original article Hit count: 239

Greetings all,

I need help combining some htaccess rewrites, these crazy regular expressions screw with my head.

So I have a folder structure something like this:

     /www/mysite.com/page/member/friends.php
     /www/mysite.com/page/video/videos.php
     /www/mysite.com/page/messages/inbox.php

The URLs get rewritten to this:

     mysite.com/member/friends.php
     mysite.com/video/videos.php
     mysite.com/messages/inbox.php

(Notice the /page/ folder is hidden in the url, but I keep it on the server for better file organization)

The rewrite rules look something like this: (I'm new so correct me if they are flawed)

     RewriteRule ^video/(.*)$ /page/video/$1 [NC]
     RewriteRule ^member/(.*)$ /page/member/$1 [NC]
     RewriteRule ^messages/(.*)$ /page/messages/$1 [NC]

Now, I also need to do a completely different rewrite to a file called lobby.php inside of the member folder:

After the original rewrites, a sample url looks like:

     mysite.com/member/lobby.php?member=pws5068

I need a new rewrite to make it look like this:

     mysite.com/pws5068

Thank you for bearing with my super-long question here. How can I make this happen?

© Stack Overflow or respective owner

Related posts about .htaccess

Related posts about friendly-url