I wanted the help of how to create a public link to my profile with php (meusite.com/usuario) as in Linkedin and instagram

Asked

Viewed 67 times

-2

A link similar to Linkedin with a custom url with the user name (meusite.com/user), it would be visible to everyone and the user could share this link with anyone. I have created the profile and user information but am not sure how to create this custom link.

1 answer

1

To create custom / friendly Urls, you will need to use some route system in your project. Basically it is a place where you specify the Urls that your site/api has and which file will run when each url is accessed.

If you are using a web framework, it probably already has something integrated and that you can use. If you are doing everything using only PHP, Html, etc... you can look for some PHP-ready class to help you with this, I will leave an example below, but recommend to take a look at others and to see which one suits you best:

https://github.com/dannyvankooten/PHP-Router

You can also create your own route schema or urls using/configuring . htaccess to redirect the urls to the corresponding scripts, but it may take more work. I will leave here a tutorial on how to create your own:

https://alexandrebbarbosa.wordpress.com/2019/04/17/phpconstruir-um-sistema-de-rotas-para-mvc-primeira-parte/

If you have the option to use some framework in the project, I strongly recommend it, because it will probably already have all these routes and many other features ready and well organized. If you don’t want to leave PHP, the Laravel is an excellent option.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.