Social network forwarding htacess

A quick question for you guys, I am creating a php / mysql site and I am facing a little problem, I have profiles on my site where a random user profile will have the following link for example: username = a

What I would like to do is show something like this in the address bar:

Also, if someone types in:, they should take it to the profile "abc", which is actually

Any ideas? Thanks in advance!


source to share

2 answers

I'm not 100% sure how to do this with root / level, but I think this should work:

RewriteEngine on
RewriteBase /
RewriteRule ^([^/\.]+)/?$ profile.php?username=$1 [L]


Here's a real neat site that you can use to test your rules.



What you are looking for is mod rewrite. There are a couple of decent generators. Play with them:



All Articles