动态虚拟主机在Laravel中出现500错误

I'm trying to make a dynamic developing environment with virtual host. Now i have:

<VirtualHost *:80>
   UseCanonicalName Off
   VirtualDocumentRoot "C:\xampp\htdocs\%1\public"
   # available aliases to use
   ServerAlias *.dev
</VirtualHost>

And it works for the default route of Laravel:

Route::get('/', function () {
    return view('home.index');
});

But any other route will give me a 500 error of to many internal redirects. I use Laravel 5.2 without any changes at all except for the routes.php and some default changes.

When I assign the domain like this as VirtualHost it works all just fine:

<VirtualHost *:80>
  ServerName example.dev
  VirtualDocumentRoot none
  DocumentRoot "C:\xampp\htdocs\example\public"
</VirtualHost>

How can I fix this problem so I can use dynamic domain names so I don't have to add all domains manually.

Thank you in advance, Stefan Fransen

Edit

When I use this:

http://example.dev/index.php/test

The page is loading correctly but this is not what I want. So how do i remove the index.php from the url? i've checked and al modules are loaded correctly this is my .htaccess:

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

    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]

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

Edit

Found out that when I changed RewriteRule ^ index.php [L] to RewriteRule ^(.*)$ /index.php/$1 [L]

But I still don't understand why it does work on a manual added vhost but not on a dynamically generated vhost, does someone have a explanation for that?

I guess you rewrite module (mod_rewrite) is disabled. Check it in apache.conf

Maybe section Pretty URLs can help you. https://laravel.com/docs/5.1