How do you disable a parent directory but not a child sub directory in /public_html

211 Views Asked by At

My basic problem is I am using node.js server in a vps apache server.

So in my .htaccess file in the /public_html directory

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]

DirectoryIndex disabled

RewriteEngine On
RewriteRule ^$ http://127.0.0.1:35112/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:35112/$1 [P,L]

And everything works fine for my node app.

However, inside of public_html/site-1/ and/or public_html/site-2/ you see I have additional sub-directories containing different things like other Wordpress sites and what have you.

So what ends up happening with the .htaccess code above is

DirectoryIndex disabled

Prevents the other public_html sub directories from working essentially, but I remove that line then my node app homepage doesn't work.

My question basically is is there a way I can disable the parent directory of public_html/ but leave child sub directories such as public_html/site-1/ and/or public_html/site-2/ alone and working?

Any help is appreciated thank you.

1

There are 1 best solutions below

0
On

You can use a different .htaccess file in the subdirectory, and specify:

DirectoryIndex homepage.html

Unrelated:

A small tip: You can use RewriteBase for mod_rewrite.

RewriteBase /subdir

RewriteRule ^/file.html - [F,L]
# This will deny access to the file.html
#...more rewrite rules for subdir