The screen all Laravel beginner developers will most likely see and how to fix it

in #writing7 years ago

Laravel_error_page.jpg

If you are new to Laravel development, then most likely you must have come across this error page or you are currently looking for how it can be fixed.

for those who might not be familiar with the term Laravel, Laravel is a free open source PHP framework developed with the intent of creating web application following the Model-view-controller approach . It was developed by Taylor Otwell.

I had to write about this because it almost took my whole night trying to fix it, I believe this will save some time for others too.

While building my application, I was always accessing it through the public directory as follows: localhost/mysite/public and it will work very fine for me, But when i move it to the production environment the same was required of me which means that if the domain is called www.mysite.com I have to access it using the public keyword like this www.mysite.com/public. I you were the owner of the site will you accept such a url for your site? No way, once i removed the public keyword it will gladly display the below error.

Laravel_error_page1.jpg

And i quickly went to stackoverflow, if you are a developer you should be very familiar with stackoverflow, there I found different solutions with some of them resulting in breaking down my whole application links. But thanks to liaotzukai who brought a quick fix to it.

The Solution


Case 1:
Create a new file called .htaccess in your root directory if it does not exist already and add the Content which i wouldn't be pasting here but i will give a link to his profile where you can get this code.

case 2:
If the file is already available in your root directory then just replace the existing code with the one on his page.

I haven't included the code here because it is a sensitive code, you can get the code through liaotzukai's profile on git and you are good.

I hope this saves you some quality time.