示例:

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

To view the route above, I must navigate to public/index.php/get.

I've viewed quite a few SO posts and googled around trying different things and it hasn't made a difference (yes I restart apache every time).

以下是我在公共目录中的.htaccess:

<IfModule mod_rewrite.c>
    Options +FollowSymLinks
    RewriteEngine On
</IfModule>

# For all files not found in the file system, reroute the request to the
# "index.php" front controller, keeping the query string intact

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

What could be causing this still? I'm running Ubuntu.

推荐答案

Do you have mod_rewrite installed and enabled on apache? Try to remove the if lines ( and ) and see if it throws an error when you try to load the website. If it does, run sudo a2enmod rewrite and restart apache.

这是最重要的.htaccess我在公共/目录上的权限:

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

Laravel相关问答推荐

使用MAATWebSite/EXCEL导入Exel时,不会创建Laravel模型

Laravel Blade 模板 @foreach 订单

如何监控 Laravel 队列是否正在运行?

如何更改 ember-cli 中的 dist 文件夹路径?

导航栏品牌中的 Laravel 动态页面标题

Laravel 和 PHPStorm 项目的 gitignore 中包含什么?

Laravel 说 Auth guard [] 没有定义

Laravel 5 环境配置数组?

约定表名(带下划线)

扩展 Eloquent 的类的构造函数

安装后在 Lumen 中找不到页面

WhereHas Laravel 中的关系计数条件是什么

Laravel Mail 发送Electron邮件但返回 false

Laravel - DecryptException:'MAC 无效'

Laravel 表:只能有一个自动列,并且必须定义为键

在 Laravel 中结合 AND/OR Eloquent的查询

如何获取 Laravel 块的返回值?

如何让 Laravel 将 View 的Content-Type标头返回为application/javascript?

Laravel s3 多桶

如何在 Laravel 5 中验证 RESTful API?