Let’s start with an example,
I have domain (abc.com), and have page abc.com/data-list.
I want to disable user from typing in address bar abc.com/data-list because I used javascript to access content section or refresh content section without refreshing master page. So URL in browser not change and stay at abc.com but in content there is change. If user type abc.com/data-list in address bar, master page is not loaded and only show content without css or js from master page. Any Idea?
How to redirect url from typing in address bar? ex: if user type abc.com/data-list it will redirect to abc.com, but if abc.com/data-list accessed from backend (like from href) there is not redirect to abc.com
Or any correct way to implement refresh content only without refreshing master page with url change depend on it’s content?
Thanks
2
Answers
Add a HTTP parameter to the backend redirect to the page. Then on the data-list page, before loading the content, check from the backend if the HTTP parameter was passed. If it is not defined, then the user likely accessed from a URL, and you can redirect the user to the main site.
If you are trying to only allow ajax calls then laravel provides a convenient method on the
Request
class to check if it is an ajax call. you can also create a Middleware so that you can conveniently put it into multiple routes.