Search code examples
phplaravelapache.htaccesslumen

Lumen 500 Internal Server Error when using any route (windows)


I've been stuck trying to figure out why I can't get my lumen project working with xampp.

It works fine when serving using: php -S localhost:8000 -t public

But when I use xammp, It seems like it works fine until I try to use any route.

For example: http://my-api.test/v1.1/ shows

Lumen (8.2.4) (Laravel Components ^8.0)

which is what I expect. However, if I try: http://my-api.test/v1.1/spec then the response is

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

I know the route is supposed to work, since it works when serving using the php command.

Looking at the apache error logs I can see that it was redirecting too many times.

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary.

I've looked at similar issues on stackoverflow and elsewhere but could not find a solution.

Here is my vhosts file:

<VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs/my-api/public"
    ServerName my-api.test

    Alias   "/v1.1/"        "C:/xampp/htdocs/my-api/public/"
 <Directory "C:/xampp/htdocs/my-api/public">
     Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        Allow from all
  </Directory>
</VirtualHost>

and my .htaccess file which is in my public directory:

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

    RewriteEngine On
    RewriteBase /v1.1/


    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} (.+)/$
    RewriteRule ^ %1 [L,R=301]

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

I'm using lumen 8.2.4 and xampp on windows. Any help would be appreciated!


Solution

  • My solution was to actually disable my antivirus. It was causing me issues with my ftp connection (different project) and after disabling it, both my ftp connection issue and this issue were fixed.

    Hope this can help someone else in the future!