Steps to make link like www.facebook.com/Lukavyi ? Must every user have separate php file to possess such link? I understand, that you could in some way change url with apache, but is link being transformed back, when user clicks it?
You can do this with Apache's
mod_rewrite URL rewrite engine. You are able to specify a URL pattern and direct all demands to some page or PHP script of your choosing.
It functions by developing a
.htaccess file and setting the guidelines inside. For instance:
Options +FollowSymLinks RewriteEngine On RewriteRule ^users/(.*)$ users.php?username=$1
The very first two rows make certain the rewrite engine is enabled, and also the third one orders all incoming demands for addresses like
/users/MyUserName to become rerouted internally to
users.php?username=MyUserName. The consumer won't begin to see the final address, just the "clean" version.
If you do not want the
users/ part within the URL and rather want
yoursite.com/MyUserName to operate rather, you will need to produce a front controller which will handle all incoming demands.
By utilizing .htaccess and mod_rewrite you are able to handle this.
You would like every user to possess it's own URL like
but would like your server to call
www.example.com/user.php?name=UserName you produce a .htaccess such as this:
RewriteEngine on RewriteRule ^user/(.*)$ /user.php?name=$1 [L]
When you get a mistake or it does not work, try adding this code on the top from the .htaccess:
[L] inside your .htaccess may prevent your browser from redirecting to
user.php?name=UserName but still shows
/user.php?name=UserName can be used. Using
[R] will redirect.