Change the site configuration file to block listing out files in the directory - apache2 + Ubuntu

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP








up vote
2
down vote

favorite












When I access a directory hosted by Apache that does not have a index.php file or similar, Apache lists the content of the directory for me. How can I block this? I'm using Apache2 on Ubuntu.










share|improve this question



























    up vote
    2
    down vote

    favorite












    When I access a directory hosted by Apache that does not have a index.php file or similar, Apache lists the content of the directory for me. How can I block this? I'm using Apache2 on Ubuntu.










    share|improve this question

























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      When I access a directory hosted by Apache that does not have a index.php file or similar, Apache lists the content of the directory for me. How can I block this? I'm using Apache2 on Ubuntu.










      share|improve this question















      When I access a directory hosted by Apache that does not have a index.php file or similar, Apache lists the content of the directory for me. How can I block this? I'm using Apache2 on Ubuntu.







      server apache2






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 16 at 21:36









      vidarlo

      7,21642140




      7,21642140










      asked Feb 14 at 16:18







      user794322



























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote













          In the appropriate <Directory> stanza. For instance it may look like this:



          <Directory /www/somefolder>
          Options Indexes FollowSymLinks
          AllowOverride None
          </Directory>


          Change this into



          <Directory /www/somefolder>
          Options -Indexes FollowSymLinks
          AllowOverride None
          </Directory>


          If there is no Options... line, you can add one with the content Options -Indexes for any <Directory...> stanza. The options are separated by a space ().



          Note the - in front of Indexes. This is also covered briefly in the Apache documentation.



          The index are generated by mod_autoindex.






          share|improve this answer




















          • Thanks, should i make a new file with the content you provided in the example directory /var/www/filer?
            – user794322
            Feb 16 at 11:03










          • No, the best solution is to edit your configuration.
            – vidarlo
            Feb 16 at 11:35










          • I tried editing the apache2.conf file and restarted the server, but it didn't work. How can i access the folder trough localhost? When trying to access the folder in the browser, i get the custom error page.
            – user794322
            Feb 16 at 11:56











          • @20_90 The default config file for default host is /etc/apache2/sites-available/000-default.conf. You can also add this to the <Directory /var/www/> stanza of /etc/apache2/apache2.conf. Simply put a - in front of Indexes.
            – vidarlo
            Feb 16 at 21:33










          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1006191%2fchange-the-site-configuration-file-to-block-listing-out-files-in-the-directory%23new-answer', 'question_page');

          );

          Post as a guest





























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote













          In the appropriate <Directory> stanza. For instance it may look like this:



          <Directory /www/somefolder>
          Options Indexes FollowSymLinks
          AllowOverride None
          </Directory>


          Change this into



          <Directory /www/somefolder>
          Options -Indexes FollowSymLinks
          AllowOverride None
          </Directory>


          If there is no Options... line, you can add one with the content Options -Indexes for any <Directory...> stanza. The options are separated by a space ().



          Note the - in front of Indexes. This is also covered briefly in the Apache documentation.



          The index are generated by mod_autoindex.






          share|improve this answer




















          • Thanks, should i make a new file with the content you provided in the example directory /var/www/filer?
            – user794322
            Feb 16 at 11:03










          • No, the best solution is to edit your configuration.
            – vidarlo
            Feb 16 at 11:35










          • I tried editing the apache2.conf file and restarted the server, but it didn't work. How can i access the folder trough localhost? When trying to access the folder in the browser, i get the custom error page.
            – user794322
            Feb 16 at 11:56











          • @20_90 The default config file for default host is /etc/apache2/sites-available/000-default.conf. You can also add this to the <Directory /var/www/> stanza of /etc/apache2/apache2.conf. Simply put a - in front of Indexes.
            – vidarlo
            Feb 16 at 21:33














          up vote
          3
          down vote













          In the appropriate <Directory> stanza. For instance it may look like this:



          <Directory /www/somefolder>
          Options Indexes FollowSymLinks
          AllowOverride None
          </Directory>


          Change this into



          <Directory /www/somefolder>
          Options -Indexes FollowSymLinks
          AllowOverride None
          </Directory>


          If there is no Options... line, you can add one with the content Options -Indexes for any <Directory...> stanza. The options are separated by a space ().



          Note the - in front of Indexes. This is also covered briefly in the Apache documentation.



          The index are generated by mod_autoindex.






          share|improve this answer




















          • Thanks, should i make a new file with the content you provided in the example directory /var/www/filer?
            – user794322
            Feb 16 at 11:03










          • No, the best solution is to edit your configuration.
            – vidarlo
            Feb 16 at 11:35










          • I tried editing the apache2.conf file and restarted the server, but it didn't work. How can i access the folder trough localhost? When trying to access the folder in the browser, i get the custom error page.
            – user794322
            Feb 16 at 11:56











          • @20_90 The default config file for default host is /etc/apache2/sites-available/000-default.conf. You can also add this to the <Directory /var/www/> stanza of /etc/apache2/apache2.conf. Simply put a - in front of Indexes.
            – vidarlo
            Feb 16 at 21:33












          up vote
          3
          down vote










          up vote
          3
          down vote









          In the appropriate <Directory> stanza. For instance it may look like this:



          <Directory /www/somefolder>
          Options Indexes FollowSymLinks
          AllowOverride None
          </Directory>


          Change this into



          <Directory /www/somefolder>
          Options -Indexes FollowSymLinks
          AllowOverride None
          </Directory>


          If there is no Options... line, you can add one with the content Options -Indexes for any <Directory...> stanza. The options are separated by a space ().



          Note the - in front of Indexes. This is also covered briefly in the Apache documentation.



          The index are generated by mod_autoindex.






          share|improve this answer












          In the appropriate <Directory> stanza. For instance it may look like this:



          <Directory /www/somefolder>
          Options Indexes FollowSymLinks
          AllowOverride None
          </Directory>


          Change this into



          <Directory /www/somefolder>
          Options -Indexes FollowSymLinks
          AllowOverride None
          </Directory>


          If there is no Options... line, you can add one with the content Options -Indexes for any <Directory...> stanza. The options are separated by a space ().



          Note the - in front of Indexes. This is also covered briefly in the Apache documentation.



          The index are generated by mod_autoindex.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Feb 14 at 17:48









          vidarlo

          7,21642140




          7,21642140











          • Thanks, should i make a new file with the content you provided in the example directory /var/www/filer?
            – user794322
            Feb 16 at 11:03










          • No, the best solution is to edit your configuration.
            – vidarlo
            Feb 16 at 11:35










          • I tried editing the apache2.conf file and restarted the server, but it didn't work. How can i access the folder trough localhost? When trying to access the folder in the browser, i get the custom error page.
            – user794322
            Feb 16 at 11:56











          • @20_90 The default config file for default host is /etc/apache2/sites-available/000-default.conf. You can also add this to the <Directory /var/www/> stanza of /etc/apache2/apache2.conf. Simply put a - in front of Indexes.
            – vidarlo
            Feb 16 at 21:33
















          • Thanks, should i make a new file with the content you provided in the example directory /var/www/filer?
            – user794322
            Feb 16 at 11:03










          • No, the best solution is to edit your configuration.
            – vidarlo
            Feb 16 at 11:35










          • I tried editing the apache2.conf file and restarted the server, but it didn't work. How can i access the folder trough localhost? When trying to access the folder in the browser, i get the custom error page.
            – user794322
            Feb 16 at 11:56











          • @20_90 The default config file for default host is /etc/apache2/sites-available/000-default.conf. You can also add this to the <Directory /var/www/> stanza of /etc/apache2/apache2.conf. Simply put a - in front of Indexes.
            – vidarlo
            Feb 16 at 21:33















          Thanks, should i make a new file with the content you provided in the example directory /var/www/filer?
          – user794322
          Feb 16 at 11:03




          Thanks, should i make a new file with the content you provided in the example directory /var/www/filer?
          – user794322
          Feb 16 at 11:03












          No, the best solution is to edit your configuration.
          – vidarlo
          Feb 16 at 11:35




          No, the best solution is to edit your configuration.
          – vidarlo
          Feb 16 at 11:35












          I tried editing the apache2.conf file and restarted the server, but it didn't work. How can i access the folder trough localhost? When trying to access the folder in the browser, i get the custom error page.
          – user794322
          Feb 16 at 11:56





          I tried editing the apache2.conf file and restarted the server, but it didn't work. How can i access the folder trough localhost? When trying to access the folder in the browser, i get the custom error page.
          – user794322
          Feb 16 at 11:56













          @20_90 The default config file for default host is /etc/apache2/sites-available/000-default.conf. You can also add this to the <Directory /var/www/> stanza of /etc/apache2/apache2.conf. Simply put a - in front of Indexes.
          – vidarlo
          Feb 16 at 21:33




          @20_90 The default config file for default host is /etc/apache2/sites-available/000-default.conf. You can also add this to the <Directory /var/www/> stanza of /etc/apache2/apache2.conf. Simply put a - in front of Indexes.
          – vidarlo
          Feb 16 at 21:33

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1006191%2fchange-the-site-configuration-file-to-block-listing-out-files-in-the-directory%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          Which professions warranted travel in Medieval times?

          How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

          Trouble downloading packages list due to a “Hash sum mismatch” error