skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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.

    // inside your controller function or middleware's handle function
    
    if(!$request->ajax()) { // request assumed to be accessible from parameter
      return redirect('/');
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search