Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove 'Parent Directory' link from root folder in Apache directory listing

How can I allow directory listing in Apache for a specific (root) folder and its subfolders, but without showing a link to parent of that root folder. When user is in a subfolder, the 'Parent Directory'link is displayed to navigate to its parent, but when user is at the root folder I need to remove/hide this 'Parent Directory' link so that user cannot move above that 'root' hierarchy.

like image 754
Khalid Amin Avatar asked Mar 15 '12 10:03

Khalid Amin


1 Answers

You can hide the "Parent Directory" link by adding the following to your .htaccess file:

IndexIgnore ..

But this will hide it for every directory.

If you have access to the httpd-configs you could try to remove the directive from per-server context:

<DirectoryMatch "^/(?!var/www/your-root/subfolder)">
...
</DirectoryMatch>

As long as there is no IndexIgnore directive in an higher folder it should work for you.

like image 70
lszrh Avatar answered Sep 23 '22 20:09

lszrh