How to Create Referer URL in Magento 2

Feel free to share this solution with Magento Community via social media.
When a non-logged in user tries to add the product to the wishlist, the default Magento 2 generates one referer URL and redirects that user to the login page. For example, if you write customer/account after your store URL without logging in, Magento 2 automatically redirects you to the login page using the referer URL.
You can create referer URL in Magento 2 to implement the below functionalities in your store.
Never miss Magento tips, tricks, tutorials, and news.

  • Restrict user to access order page directly without login.
  • Direct URL access restriction without logging in.
  • Restrict payments using a specific method for non-logged-in users.

Referer URL is the address of the webpage where a person clicked a link that sent them to your page. Referer is the webpage that the visitor was on before landing on your page.

Method to Create Referer URL in Magento 2

That’s it!
Follow the below solution and restrict the user to access your pages directly without login and get rid of unauthenticated users.
Something went wrong.
Thank you for subscribing.
It’s the default behaviour of the Magento 2, but what if you want the same concept in other pages and functionalities on your store also?

Get Weekly Updates

You are always welcome to mention your doubts regarding this solution in the Comments section below.

I would be glad to help you.
Thank You.




(based on 0 Reviews)