Dreni Dreni - 1 year ago 88
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?

Answer Source

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 .

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download