php - Digital Ocean Ubuntu LAMP 服务器 : Laravel cannot access router group

标签 php ubuntu digital-ocean

我最近在 Digital Ocean 上的 Ubuntu 上将 Laravel 5.1 应用程序部署到了 LAMP 设置中。

http://159.203.82.91/ 访问我的 Droplet得到我:

This Works



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

enter image description here

但它应该读

This does not!


$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

最佳答案

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

  • 确认您启用了 mode_rewrite在 Apache 。
  • 确认您输入了 AllowOverride Apache 虚拟主机配置中的指令。

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

    关于php - Digital Ocean Ubuntu LAMP 服务器 : Laravel cannot access router group,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44019217/

    相关文章:

    ubuntu - 如何在 ubuntu 20.04 焦点上下载 dotnet-sdk-2.2?

    c++ - ifstream 为不存在的文件返回 true

    ssh - 无法远程连接到Digitalocean Droplet-不允许的密码

    mysql - OperationalError 在 'reading initial communication packet' DigitalOcean 失去与 MySQL 服务器的连接

    php - 在没有提供 API key 的情况下访问 Laravel 中的数据库有多安全?

    ubuntu - 在 Ubuntu 上启动时运行命令

    Php 计数 +1 表中插入的值

    ruby-on-rails - Rails 缓存权限错误

    php - 将 HTML 文件读入电子邮件

    php - mysqli_fetch_assoc()需要参数/调用成员函数bind_param()错误。如何获取并修复实际的mysql错误?