Skip to content

Configuring Public Folder Access with .htaccess

Published: at 03:04 AM

I’m running a php app which has a “dist” folder which is supposed to be the main public folder for the app. But, I’m running the app from a sub-folder and I need to redirect all requests to the dist folder for security. How can I achieve this?

To redirect all requests to the dist folder for your PHP app, you can use a .htaccess file if your server is Apache. Here’s a basic example of how you can achieve this:

  1. Create a .htaccess file in your sub-folder (if you don’t already have one).
  2. Add the following code to redirect all traffic to the dist folder:
RewriteEngine On
RewriteBase /subfolder/
# Redirect all requests to the dist folder
RewriteCond %{REQUEST_URI} !^/subfolder/dist/
RewriteRule ^(.*)$ /subfolder/dist/$1 [L,QSA]

Make sure to replace /subfolder/ with the actual path to your sub-folder.

Explanation:

This setup should redirect all incoming requests to your dist folder while maintaining the security and structure of your PHP app.


Previous Post
Labeling Symlinks in Windows
Next Post
Customizing Kanboard's Visual Theme