The problem is, static files inside /public are NOT handled by laravel, but they are served directly by your server software.
If you are using apache2, you can deny access to a public subfolder you could place an .htaccess file inside the directory denying access:
public/custom/.htaccess
order deny,allow
deny from all
The problem is, you would have no way to authorize access to those files outside unless you use basic auth, which is extremely basic.
In order to handle complex authorization and not disrupt laravel conventions, I would place those files inside a folder inside resources (or even storage/app)
resources
| custom
| | index.html
| | image.png
| | script.js
| | style.css
Then, in your web.php create a generic route for everything inside your original folder:
Route::get('/custom/{file?}', [CustomFilesController::class, 'getFile'])
Inside the controller/route you can:
- perform your authorization
- retrieve the files from the resources (or storage) folder
- serve them in response with the appropriate content type header