How do I not display the list of directories?

0

Hello, so my question is this: I have a folder called admin and another general call, which is inside admin . Inside the admin folder I have a file called general.php so far so good, the problem is that if I access like this:

link

it enters the general folder and displays everything in it, and I do not want to display anything much less a list of directories would have how to avoid it? I tried with htaccess and did not succeed, now if I access it so it opens the file geral.php

link

I tried to use htacess as I said it like this:

RewriteEngine On 

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^geral(.*)$ geral.php
RewriteRule ^teste(.*)$ teste.php

And it keeps getting into the general folder instead of entering the general.php file

    
asked by anonymous 02.12.2016 / 15:30

3 answers

1

Add this line to the beginning of your htaccess and you're done

Options All -Indexes 
    
02.12.2016 / 18:30
1

I recommend the following readings:

Blocking Apache directories here you need to edit the httpd.conf or apache.conf file and edit the code so that it looks like the following:

<Directory "/var/www/htdocs">
    Options +indexes MultiViews
    AllowOverride None
    Order from all
    Allow from all
</Directory> 

and

Prevent listing of files and directories with .htaccess (Apache)

In this case you can choose to put the following code in .htaccess

## Impedindo a listagem de qualquer arquivo e diretório
Options -Indexes

or going a little further and preventing only some extensions from being blocked from listing example:

## Impedindo a listagem do próprio de arquivos .jpg e png
IndexIgnore .jpg, .png
    
02.12.2016 / 18:32
1

Super Fast Mode to solve this problem

  

create a blank "index.html" file and put it in the 'general' folder (JOOMLA methodology)

You can solve the problem with the blank index.html or through configuration in apache in the admin folder, according to the site .

RewriteEngine On 

RewriteRule ^([a-z]+)\/$ $1.php [NC]

This rule should do the following, when accessing the "friendly" URL will be redirected to the .php.

In other words, the client accesses the URL '/ general /' the server runs the 'general.php' file

  

link - > link

     

link - > link

Alias recommend Leo Letto's answer and also put:

Options All -Indexes 
    
02.12.2016 / 18:25