How to make link like http://www.facebook.com/Lukavyi ?
Must every user have separate php file to have such link? I know, that you can somehow change url with apache, but is link being changed back, when user clicks on it?
How to make link like www.facebook.com/Lukavyi ? Must every user have separate php file
Share
This can be done with Apache’s
mod_rewriteURL rewrite engine. You can specify a URL pattern and direct all requests to a page or PHP script of your liking.It works by creating a
.htaccessfile and setting the rules in there. For example:The first two rows make sure the rewrite engine is enabled, and the third one orders all incoming requests for addresses like
/users/MyUserNameto be redirected internally tousers.php?username=MyUserName. The user will not see the final address, only the “clean” version.If you don’t want the
users/part in the URL and instead wantyoursite.com/MyUserNameto work instead, you’ll have to create a front controller that will handle all incoming requests.