0

I'm using a shared hosting server, I installed my first Laravel 5.4 application and everything is still working fine. A few days ago I installed another Laravel 5.4 application on a different domain, but same server, but when I try to access the URL, I get 500 INTERNAL SERVER ERROR.

Below is my .htaccess code

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^public
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

I also tried the following, but same error:

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

    RewriteEngine On

    ### Add two lines for fix error 500 ###
    Options -Indexes
    php_flag xcache.cacher 0
    #######################################

    # 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>

1 Answer 1

3

You moved everything inside your public_html folder which you should not do. Only files inside /public needs to be in public_html, hence the name public. The Laravel files should be placed higher directory where it is not accessible from the public.

  1. Install Laravel with Softaculous, or with composer via SSH in /home/username/laravel
  2. Move everything in /home/username/public_html folder to /home/username/laravel
  3. Move everything in /home/username/laravel/public to /home/username/public_html and delete the public folder after move.
  4. Edit this file: /home/username/public_html/index.php
  5. Change to require '/home/username/laravel/vendor/autoload.php';
  6. Change to $app = require_once '/home/username/laravel/bootstrap/app.php';
  7. Save this file and close window.

  8. Edit this file: /home/username/laravel/server.php

  9. Change to:

    if ($uri !== '/' && file_exists('/home/username/public_html'.$uri)) {
        return false;
    }
    
    require_once '/home/username/public_html/index.php';
    

Replace username with your hosting username. :)

Sign up to request clarification or add additional context in comments.

10 Comments

Now it's showing a different error, when I try to access the domain (forumcover.com) it displays the full folder structure of the laravel framework.. When I try to access the login route (forumcover.com/login) I get NOT FOUND "The requested URL /index.php was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request."
Please remove, you leaked your database details!
Alright I' will anticipate your response. As for the database details I've changed it.
Updated the answer, this is as far as I can remember, let me know if it works or I missed some steps. :)
After following the steps above, I get "The forumcover.com page isn’t working forumcover.com is currently unable to handle this request." I moved all files and folders including "cgi-bin" directory to home/Username/laravel.... Am I supposed to leave the cgi-bin directory in home/username/public_html ?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.