Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8799973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:27:57+00:00 2026-06-14T00:27:57+00:00

How can I allow directory listing in Apache for a specific (root) folder and

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:27:58+00:00Added an answer on June 14, 2026 at 12:27 am

    I just ran into the same issue, and this was the first search result, so I thought I’d share my solution. I don’t have access to httpd-configs in my case, so I went with a different approach.

    Because I won’t be maintaining the indexed directory tree, I needed a solution that could exist just in the index root without any specific knowledge of its sub-directories. However, it does use an absolute path to the index root, so if your parent folder structure changes a lot, it may not work for you.

    What I came up with was using a CSS URL attribute selector to hide the “Parent Directory” link when it led to the parent of the index root. It leaves a blank row, but at least it’s not as intimidating as the “403 FORBIDDEN” error a user gets if they click Parent Directory one too many times.

    Theoretically, the fix should be as simple as adding one line to your index root’s .htaccess file:

    IndexHeadInsert "<style type=\"text/css\">a[href=\"/absolute/path/to/index/root/parent/\"] {display: none;}</style>"
    

    However, it seems that simple solution doesn’t work in IE because the default doctype of the html that Apache spits out is too old to use attribute selectors.

    Instead, we have to surround Apache’s generated code with our own doctype using the HeaderName and ReadmeName keywords in the htaccess file. I went with the HTML5 doctype, although there may be a more appropriate one that works.

    .htaccess file:

    Options +Indexes
    
    IndexIgnore "_index_header.html" "_index_footer.html"
    
    HeaderName "/absolute/path/to/root/index/_index_header.html"
    ReadmeName "/absolute/path/to/root/index/_index_footer.html"
    
    IndexOptions +SuppressHTMLPreamble
    

    _index_header.html file:

    <!DOCTYPE html>
    <html>
        <head>
            <title>title</title>
            <style type="text/css">
                a[href="/absolute/path/to/index/root/parent/"] {display: none;}
            </style>
        </head>
        <body>
    

    _index_footer.html file:

        </body>
    </html>
    

    (Note that the CSS selector is to the index root’s parent)

    Works in all of the latest browser versions I tested it on (FF, IE, Chrome, Safari, Opera), and also all the way back to IE 7.

    Also, now that you went through all the trouble of creating those files, you might as well make your index more snazzy. The apache doc on mod_autoindex has a bunch of options you can use to tweak things, on top of what you can do with CSS.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So for security reasons, I want to disallow http://www.domain.com/directory/ but allow that physical directory
We use a web server that does not allow directory listing. There is a
I believe that git filter-branch can allow me to do this, but I can't
How can I annotate my model so I can allow only alphabets like A-Z
I have a site that can allow me to access the mobile version of
I am wondering if there a function in php that can allow me put
Is there a standard MBEAN of JMX that can allow me to read files
As far as I know, Drupal Services Module can allow PHP scripts to communicate
When creating a child process in C++ using Windows API, one can allow inheritance
How can I allow spaces within an a numbers only validation, with a minimum

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.