I'm developing a website where users have their own sections within the site so for example if someone visits /users/index.php?uid=100 then they see the content for user ID 100 (Mark) and the user ID is stored in a session variable so as they browse various pages each page only displays the database content for Mark.
It all works fine but I'd like to use a friendlier URL so users can use the URL /users/mark instead of /users/index.php?uid=100 (I realise that the user names will need to be unique!)
I've played around with .htaccess and rewriting the URLs and tried this:
RewriteEngine On
RewriteBase /users
RewriteRule (.*) index.php\?sef=$1
Index.php then uses $sef to lookup the user's ID.
I've found two problems with this though - firstly it messes up all the paths to my CSS and javascript and secondly sub pages in the site don't work. I think my RewriteRule is the problem as it's sending all requests through index.php.
Does anyone have any tips on using friendly URLs with PHP? Do I need more specific rules in .htaccess or do I need index.php to be more intelligent with how it handles the URLS?