简体   繁体   中英

Laravel Virtual Host Request Url Not found

I'm having a problem with my laravel application using VirtualHosts, I can see the home page of laravel but when I try to make a route like advkit.dev/login I get "The requested URL /login was not found on this server." So all my routes aren't working does anyone know what I need to change in my code to make routes work. I also have set debug to true and I only get the debuging console on the home page eg advkit.dev no where else

route:

<?php

Route::get('/', function()
{
    return View::make('hello');
});

// login.blade.php
Route::get('/login', function() {
    return View::make('login');
});

hosts

127.0.0.1       www.localhost.com
127.0.0.2       advkit.dev

httpd-hosts file

<VirtualHost advkit.dev>
    DocumentRoot C:\wamp\www\advkit\public
    ServerName advkit.dev
</VirtualHost>

I had the same problem and the virtualhost setup given in the following answer worked for me: https://stackoverflow.com/a/33760330/4561150

<Directory "C:/myproject/mysubfolder/public">
   Options Indexes FollowSymLinks Includes ExecCGI
   AllowOverride All
   Require all granted
</Directory>

It sounds like Apache is ignoring your .htaccess file. You could fix that, but the better solution is to put the contents of that .htaccess file in your virtualhost. Then your virtualhost would look like this:

<VirtualHost advkit.dev>
    DocumentRoot C:\wamp\www\advkit\public
    ServerName advkit.dev

    <Directory C:\wamp\www\advkit\public>
        # Ignore the .htaccess file in this directory
        AllowOverride None

        # Rewrite URLs
        <IfModule mod_rewrite.c>
            <IfModule mod_negotiation.c>
                Options -MultiViews
            </IfModule>

            RewriteEngine On

            # Redirect Trailing Slashes
            RewriteRule ^(.*)/$ /$1 [L,R=301]

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

You can add the following lines in your .conf file.

<Directory /var/www/gloops/public>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
 </Directory>

After save the files and enable rewrite mode by the given command and restart the apache2 service.

sudo a2enmod rewrite
sudo service apache2 restart

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM