Score:0

Use DirectoryIndex while grant access only for one file

cn flag

I wanted to grant access only to index.php via .htaccess:

DirectoryIndex index.php
Require all denied
<Files "/index.php">
    Require all granted
</Files>

That works, but when I open only the directory, it shows "403 Forbidden". How can I make DirectoryIndex work?

Michael Hampton avatar
cz flag
You specified `Require all denied` so of course it is blocked. Why have you put that there?
levi-jcbs avatar
cn flag
Because, I want to grant access only to index.php.
Score:0
ru flag

Just an idea:

Perhaps you could do something more sensible as redirecting everything not index.php to another directory and deny there.

DirectoryIndex index.php

RedirectMatch ^/(?!index\.php$|$)(.*) /test/$1
ezra-s avatar
ru flag
@levi-jcbs thanks for the edit!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.