Receiving 500 Internal Server Error when using nice URLs (?)

Published 2 years ago by andreasb

Good morning everyone,

I am following Jeff's videos to learn Laravel and I love it!

Obviously, while playing around a bit with the concept of routes etc I run into my first error:

Internal Server Error

Now, what do it do? My routes.php looks like this:

Route::get('/', 'StaticPagesController@welcome');

Route::get('about', 'StaticPagesController@about');

When I go to mydomain.com everything works. If i go to mydomain.com/about I get the 500 error.

Now both my storage and bootstrap/chache directories have the proper permissions (750 to let the webserver use it). Just to make sure, I changed both to 777 but that didnt work either.

My Apache error log is - unfortunately - empty.

If I change the route to

Route::get('about', function(){return "hello";});

I still get the same 500 error.

Now then I thought it must be the .htaccess, which currently looks like this:

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

    AuthType Basic
    AuthName "Nothing to see"
    AuthUserFile /<path>/public/.htpasswd
    Require valid-user
    
    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]
</IfModule>

If I remove the authentification part or use the alternative provided by the Installation Documentation:

Options +FollowSymLinks
RewriteEngine On

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

(I omitted the auth part for testing)

....it still doesn't work.

Since I am running out of ideas I kindly ask for your help :-)

Thanks Andreas

Best Answer (As Selected By andreasb)
andreasb

With the support of my webhoster I learned that I forgot the

RewriteBase /

and now it works with the following .htaccess:

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

    AuthType Basic
    AuthName "Nothing to see"
    AuthUserFile /<path>/public/.htpasswd
    Require valid-user
    
    RewriteEngine On

    RewriteBase /

    # 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]
</IfModule>

I hope this helps someone sometime :)

Andreas

andreasb

With the support of my webhoster I learned that I forgot the

RewriteBase /

and now it works with the following .htaccess:

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

    AuthType Basic
    AuthName "Nothing to see"
    AuthUserFile /<path>/public/.htpasswd
    Require valid-user
    
    RewriteEngine On

    RewriteBase /

    # 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]
</IfModule>

I hope this helps someone sometime :)

Andreas

Please sign in or create an account to participate in this conversation.