Create facebook style profile link

0

Hello, I would like to know how to appear in the link of the client profiles of my facebook link style project (facebook.com/profilename). Because I can not get by without getting (site.com/perfil.php?per=profilename), (being "? Per=" the variable of the name of the profiles), I would like to make a scheme that would remove this "perfil.php? per="for by direct. Thanks!

    
asked by anonymous 06.01.2018 / 23:23

1 answer

2

To make such a URL, you can use a design pattern called Front Controller, where all requests from your site will be managed by index.php

Example of how URLs with front-controller are:

seusite.com/categorias
seusite.com/categoria/1
seusite.com/categoria/create

Understanding the concept and applying to your project would look like this. When a request hits your index.php (example: yourite.com/ProfileName) your index will search your database if that username exists. If it exists it brings the view with the user information.

It's very simple to build a Front Controller in a pure PHP project, but an alternative is to work with a PHP framework that already has at its core this design pattern and many others that facilitate the development of applications, always following the best practices. I'll leave the link for some case you are interested.

Hugs!

    
07.01.2018 / 00:47