2Foot 2Foot - 10 months ago 66
Apache Configuration Question

Laravel 5.2 all routes work EXCEPT the home route

I have a project that I am moving from my development server to my hosting server. I have set the Document route in the Apache config to the public folder. The strange behavior I am getting is that all routes work EXCEPT the home route... or the '/' route. This all works on my development server but I never set the document root to the public folder. So aside from that, I expected it to work. It's very strange. www.example.com loads a blank page, no error. However, www.example.com/events works fine, or any sub-route for that matter. I git pushed the entire project up to the production server (if that sparks any ideas). For now, I have included my current .htaccess file below. I have tried many things with the .htaccess as I am assuming this is the problem but with no luck! Looking forward to any suggestions!

Options +FollowSymLinks
RewriteEngine On

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

I have made all permissions on files to 644 and folders to 755. Then I set permissions on the storage and public folders to 777 after that just to ensure they had the access they needed - I can restrict them once I figure out my problem(s). This is the first Laravel based project I've ever moved to production so please don't take anything for granted and throw your ideas at me! :) Finally, I am getting nothing in the error logs when I try to access the main page at all. They remain empty.

UPDATE: When I do this to my routes file I do not get any text, still just the WSD (White Screen of Death):

Route::get('/', function () {
return 'Hello World';

Answer Source

Finally figured it out! Hopefully this will help others...

I had to comment out one of the first lines in the index.php found in the public folder. This is the line you are looking for:

if (file_exists(__DIR__ . $_SERVER["REQUEST_URI"])) return false;

If you think about it for a minute it makes sense, but was so frustrating. Once you comment out that line you should be good to go! Enjoy!