skip to Main Content

How can I block my url, e.g. myapp.com/images on production? By typing this address, the user can check all available images from the server. I can not connect with images while working locally, but I have this problem on production. Thank you for your help

2

Answers


  1. You can disable the file listing by adding the following to your .htaccess file (assuming you are running Apache):

    Options -Indexes
    
    Login or Signup to reply.
  2. You can also use middleware to restrict access to this site. This also provide you an option to give access to a certain users (especially with login accounts)

    RestrictionsMiddleware.php

    ...
         public function handle($request, Closure $next)
        {
             if (Auth::guard('yourguard')->check() || Auth::guard('otherguard')->check() ) {
                        return $next($request);
                }else{
                    return redirect('/home');   
                }
    
        }
    

    then if you want to total restriction then just redirect to any landing page you want.

                return redirect('/home');   
    

    You just declare it on the controller or function you want to have this restriction. in my case i declare it to the construct of the controller

    MyController.php

        public function __construct()
        {
            $this->middleware('restriction_middleware');
        }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search