Access Public Directory via URL with htaccess

The .htaccess file can be used to allow public access to specific directories on your website through the URL. By using this file, you can easily control access.

If you want to allow public access to the JS, CSS, and Font directories inside the public folder and access them from a different URL, you can add the following code to your .htaccess file:

 Options +Indexes
Options +FollowSymLinks
Options -MultiViews

RewriteEngine On

# Allow access to specific directories for all users
RewriteRule ^assets/(js|css|fonts)/(.*)$ /public/$1/$2 [L]

In the code above, the "RewriteRule" directive allows access to the "js", "css", and "fonts" directories within the "assets" directory from a different URL. The code also enables directory listing and symbolic link following, disables content negotiation, and sets the RewriteEngine on to enable URL rewriting if necessary.

Please note that this code may not be suitable for all scenarios and you should exercise caution when editing the .htaccess file. It is also recommended that you test any changes thoroughly before making them live on your website.