0

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
    </IfModule>
    RewriteEngine On

    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://takaful.hsn93.com/$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]

</IfModule>

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

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

Forbidden

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

Hasan alattar
  • 347
  • 3
  • 19
  • 1
    [Laravel ships with an `.htaccess`](https://laravel.com/docs/5.0/installation#pretty-urls) - don't modify those parts unless you need something special. The `403` is likely unrelated to `.htaccess`, just an Apache config problem. Try removing your `.htaccess` to confirm. [There](https://stackoverflow.com/questions/18447454/apache-giving-403-forbidden-errors) are [many](https://stackoverflow.com/questions/6959189/apache-virtualhost-403-forbidden) questions/answers [here](https://stackoverflow.com/questions/21394871/apache-gives-me-403-error-when-trying-to-access-on-server) about fixing 403s. – Don't Panic Apr 05 '20 at 08:42
  • @Don'tPanic laravel works perfectly expect for the url (/) it doesnt get routed to index.php .. thats why i had to change it .. i posted my virtual host configuration which i believe is right .. i'll have a second look on what you 've posted but earlier i couldnt find similar problem to mine – Hasan alattar Apr 05 '20 at 09:14
  • @Don'tPanic thanks ,, i now put the original htaccess file after finding out (index.php) need to be indexed in the httpd.conf file – Hasan alattar Apr 05 '20 at 09:36

1 Answers1

0

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
</IfModule>
Hasan alattar
  • 347
  • 3
  • 19
  • 1
    They should be on one line - `DirectoryIndex index.html index.php`. When in doubt, [check the docs!](https://httpd.apache.org/docs/2.4/mod/mod_dir.html#directoryindex) – Don't Panic Apr 05 '20 at 09:38