Dreni Dreni - 4 months ago 34
Apache Configuration Question

Prevent direct access to subfolder, redirect instead

The structure looks like this:


I want to prevent direct access when someone visits mysite.com/subfolder. The user should instead be directly redirected to the index.html on the parent folder.

How is this possible with .htaccess?


Create an htaccess file in the subfolder and add the following :

RewriteEngine on

RewriteRule ^$ /index.html [L,R]

Remove the R flag if want to internally redirect (without changing the url) /subfolder to /index.html .