【问题标题】:Lumen API routes not working. Only 'public/' route worksLumen API 路由不工作。只有“公共/”路线有效
【发布时间】:2017-11-30 19:32:05
【问题描述】:

我已经安装了 Lumen 并使用 de composer 创建了一个新项目。 我的 Apache24/htdocs 文件夹下有 de 项目文件夹(我使用的是 Windows 10)。

'localhost/myapp/public/' 工作正常。当我创建一个新路由时出现问题,比如'/test'返回一些字符串:

$app->get('/test', function () use ($app) {
return 'test'; });

然后,当我尝试“localhost/myapp/public/test”时,我收到 404 错误。

我的 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}]

我的 Apache 配置有 AllowOverride All 并且 LoadModule rewrite_module modules/mod_rewrite.so 已启用。

尝试了laravel 4 all routes except home result in 404 error 中的建议,但都没有解决我的问题...

有什么帮助吗?

【问题讨论】:

  • 你试过RewriteBase /myapp/public吗?

标签: apache .htaccess mod-rewrite routes lumen


【解决方案1】:

谢谢@Mike。 我将 RewriteBase /myapp/public 添加到我的 .htaccess 中,然后它就起作用了。

【讨论】:

    猜你喜欢
    • 2017-07-28
    • 2018-12-29
    • 2021-05-02
    • 2011-05-12
    • 1970-01-01
    • 2015-10-04
    • 1970-01-01
    • 2017-10-31
    • 2019-06-23
    相关资源
    最近更新 更多