流明API路由不起作用。只有' public /'路线工作

时间:2017-06-27 16:30:02

标签: apache .htaccess mod-rewrite routes lumen

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

本地主机/ myapp / public /'工作良好。当我创建新路线时会出现问题,例如' / test'返回一些字符串:

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

然后,当我尝试本地主机/ 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中的建议已经尝试过了,但没有一个能解决我的问题......

任何帮助?

1 个答案:

答案 0 :(得分:0)

谢谢@Mike。 我在我的.htaccess中添加了RewriteBase / myapp / public,然后就可以了。