无法找到Laravel路线404

时间:2018-07-05 09:27:24

标签: php laravel

我更换了电脑并在Windows 10 WSL上安装了指示灯。主要索引有效/但路由无效。这是我的虚拟主机文件。

<VirtualHost 127.0.0.2:80>
    DocumentRoot /var/www/devroot/lara/panel/public
    DirectoryIndex index.php
    <Directory "/var/www/devroot/lara/panel/public">
        Options All
        AllowOverride All
        Order Allow,Deny
        Allow from all
    </Directory>
</VirtualHost>

这是项目中的htaccess

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

    RewriteEngine On

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

我访问路线链接时出现错误。

Not Found

The requested URL /lara/panel/public/admin was not found on this server.
Apache/2.4.18 (Ubuntu) Server at localhost Port 80

2 个答案:

答案 0 :(得分:0)

您的VHost设置不正确。 Laravel默认服务于localhost:8000。使用php artisan serve后,您会看到它作为输出。试试这个:

<VirtualHost *:80>
    DocumentRoot /var/www/devroot/lara/panel/public
    DirectoryIndex index.php
    <Directory "/var/www/devroot/lara/panel/public">
        Options All
        AllowOverride All
        Order Allow,Deny
        Allow from all
    </Directory>
</VirtualHost>

答案 1 :(得分:0)

问题是htaccess被隐藏了,我不好,我将其从_htaccess修改为.htaccess,现在可以正常工作了。