Document root Apache 2 cannot find routes from the Apache

Asked

Viewed 1,233 times

0

Assuming we are on a linux server we have the following password.

the root Document pointed to

<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/laravel/public
ServerName site.com.br

then we have a problem because the framework cannot find the defined routes in the Routes.php file I think this is due to the root Document being pointing to the public folder from there it does not find the routes www.site.com/route someone would have a solution for this, if that’s the real problem.

1 answer

1

I believe the problem is occurring because you have not enabled the option of override in its configuration.

Try to leave the Virtual Host like this:

<VirtualHost *:80>
  ServerName site.com.br
  DocumentRoot "/var/www/html/laravel/public"
  <Directory "/var/www/html/laravel/public">
    AllowOverride all
    DirectoryIndex index.php
  </Directory>
</VirtualHost>

Also check if in the folder public of your project there is a file called .htaccess, the default content of this file in Laravel is as follows:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

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

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

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
  • Enable apache2 mod_rewrite also if it is disabled.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.