首页 文章

Digital Ocean Ubuntu LAMP服务器:Laravel无法访问路由器组

提问于
浏览
0

我最近在数字海洋上的Ubuntu上为LAMP设置部署了一个Laravel 5.1应用程序 .

http://159.203.82.91/访问我的Droplet让我:

这个作品

我已经设置了 1.0 的路由前缀(见下文),http://159.203.82.91/1.0

enter image description here

但它应该读

这不!

$router->group(['middleware' => 'cors'], function(Router $router) {
        $router->get('/', function () { return 'This Works'; });
        $router->group(['prefix' => App\Http\Controllers\Controller::API_VERSION], function(Router $router) {
                $router->get('/', function () { return 'This does not!'; });

为什么我可以访问 index 而不是像 /1.0 这样的子路由?


root@phpmyadmin-512mb-nyc3-01:/var/www/html# cat public/.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>

enter image description here

1 回答

  • 1

    请检查以下几点以解决您的问题 .

    • 确认您在Apache中启用了 mode_rewrite .

    • 验证是否在您的Apache虚拟主机配置中放置了 AllowOverride 指令 .

    Follow this如果您不知道该怎么做 . 在本指南中,您只需要了解如何启用 mod_rewrite 并编辑默认虚拟主机以允许使用 .htaccess .

相关问题