PHP Developer,
One way to do this you want is to use Friendly Urls like the mod_rewrite apache, capture requests and pass them to a file, as most PHP frameworks do today.
So when a user accesses for example nomedosite.com/yokojoao
he’ll be accessing nomedosite.com/index.php
passing by yokojoao
as a parameter, which your PHP script can handle to identify the user.
Remember that in this URL scheme everything that is passed after the nomedosite.com/
would be sent as parameter for the script.
If you are using Apache and it is with active mod_rewrite you should have at the root of the site a file called .htaccess
, yes . htaccess, with nothing before the point and no extension after access.
The contents of the file can be something like:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^busca/(.*)$ ./buscar.php?query=$1
RewriteRule ^/(\d+)*$ ./login.php?username=$1
In this case the two Rewritecond inform that conditions trigger the rules below, below there are two rules, I put a search to show how you could continue with a few pages after the / , if this rule did not exist the /busca
would be understood as a username.
The above script redirects any nomedosite.com/usuario
for /login.php
passing the username as $_GET['username'] and if anyone searches nomedosite.com/busca/algumacoisa
it passes $_GET['query'] with value of something to ./buscar.php
This you can do in two ways. One of them is to use files. htaccess to redirect each user to a specific link according to the parameter. The other way is to use . htaccess to identify the whole parameter after the
/
as a$_GET
and then in your application you get the value of his Dice that would turn something$_GET['yokojoao']
– KhaosDoctor