Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Routes not working after deploying Laravel 5 project into hosting

Tags:

laravel-5

I just uploaded my Laravel 5 proyect to the hosting server. The index page almost works, but every link is broken. Every single route returns an Internal Server Error message. This is the actual message:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

I already set storage folder permissions to 777, but I don't even get an error log.

Any suggestions?

like image 567
Allfarid Morales García Avatar asked Apr 12 '15 05:04

Allfarid Morales García


1 Answers

In the end I could solve it adding

RewriteBase /

to my .htaccess file in the public folder.

This is my complete .htaccess file:

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

RewriteEngine On
RewriteBase /

# Redirect Trailing Slashes...
RewriteRule ^(.*)/$ /$1 [L,R=301]

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

The most strange thing is I already had tried that, because that's how I solved the same issue with Laravel 4. What made it work was changing

RewriteBase /

to the incorrect

RewriteBase ../

and then changing it back to

RewriteBase /

And misteriously it solved.

I hope this helps anyone. It's 5:22 and I need some sleep

like image 173
Allfarid Morales García Avatar answered Sep 23 '22 08:09

Allfarid Morales García