Apache Setup .htaccess RewriteRule With Laravel

- 1 answer

im setting up (laravelproj/public/.htaccess)

the example ones that I've worked on 2 different servers as follows:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews -Indexes
    RewriteEngine On

    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$$1 [R,L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]


now I'm trying it on cent OS apache (httpd) (if that matters) enter image description here and when i put in the link ( < apache returns the following:

i dont have any other problem except this link ^ with no parameters ^


You don't have permission to access / on this server.

so to make it work i'd to comment this line (condition where it checks if the requested isnt directory:

 #RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^ index.php [L]

which make sense because / is of course a directory ..

but why did this .htaccess configuration worked on all other machines? what is different on this machine that makes this condition returning a forbidden from apache



i found the problem is that httpd.conf

doesnt index (index.php) files just (index.html)

so i modified it

<IfModule dir_module>
    DirectoryIndex index.html
    DirectoryIndex index.php