How to mask URL in Laravel?
For example, when a user post this https://somewhere.com/anywhere.php and I want to mask it to become something like https://mywebsite.com/rxxx then https://mywebsite.com/rxxx redirects to https://somewhere.com/anywhere.php
I will walk you through with some few steps
1.first create a table in your database with a field that will hold the URL submitted by the user and also a field for a generated id. Note, you can use the id of the table but I would prefer you generate a random but unique id for each URL.
- Next, anytime someone tries accessing the masked URL in our case www.mywebsite.com/rxxx, what happens behind the scene is that on your backend, you will get the id from the link which is rxxx and search against your table(the one you created in step one) and get the actual link then redirect the person to the actual website. In that way you can track the number of times the URL was clicked, etc.