I am working on a social networking site. Something that I would like to do is have the user’s username come after my websites name… like example.com/myusername. I know I could do something using $_GET variables where it would look like example.com/?u=myusername, but we think that having just the username after after the domain would look cleaner and be easier for users to navigate.
Thanks in advance,
JS
You can setup a rewrite rule to direct all non-existent requests to your
index.php(or really whatever script you want to use). Then just inspect the$_SERVER['REQUEST_URI']and pull out the username.Here’s a basic set of rewrite rules (for apache):
And in your case:
That would allow you to also use:
example.com/username/posts/newest, and pull out the various ‘parts’.