skip to Main Content

I had reinstalled apache and after I configured it again, my Laravel applications don’t work anymore and it shows me the directory structure instead.enter image description here

Here is my httpd configuration:
enter image description here

2

Answers


  1. you can add .htaccess file to root’s of project and add these lines

    <IfModule mod_rewrite.c>
        RewriteEngine On
    
        RewriteRule ^(.*)$ public/$1 [L]
    </IfModule>
    
    Login or Signup to reply.
  2. If you’ve "reinstalled Apache" then the default DirectoryIndex is just index.html. You need this set to index.php in order to serve your Laravel front-controller.

    When Apache does not find the DirectoryIndex document (eg. index.html) when requesting a directory and directory indexes/listings (mod_autoindex) are enabled (the default) then Apache generates a directory listing as you are seeing here.

    You need to set index.php as the DirectoryIndex, for example:

    <Directory /var/www/html/wafacashapp>
        AllowOverride All
        Require all granted
        DirectoryIndex index.php
    </Directory>
    

    Alternatively, you can set the DirectoryIndex in your .htaccess file – if you have one. (If you aren’t using .htaccess files then you should disable .htaccess overrides by setting AllowOverride None.)

    You should also consider disabling directory indexes/listings, so as to not expose the contents of your directories should a DirectoryIndex document not be found. For example, in the same <Directory> container (or .htaccess file):

    Options -Indexes
    

    The user will then be served a 403 Forbidden instead of a directory listing.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search