Digital Ocean Ubuntu LAMP 服务器:Laravel 无法访问路由器组
Digital Ocean Ubuntu LAMP server: Laravel cannot access router group
我最近将 Laravel 5.1 应用程序部署到 Digital Ocean 上 Ubuntu 上的 LAMP 设置。
在 http://159.203.82.91/ 访问我的 Droplet 让我:
This Works
我设置了 1.0
的路由前缀(见下文),http://159.203.82.91/1.0:
但它应该是
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 ^(.*)/$ / [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>
---
请检查以下几点以解决您的问题。
- 确认您在 Apache 中启用了
mode_rewrite
。
- 确认您在 Apache 虚拟主机配置中放置了
AllowOverride
指令。
Follow this 如果您不知道该怎么做。从指南中,您只需要了解如何启用 mod_rewrite
并编辑您的默认虚拟主机以允许使用 .htaccess
.
我最近将 Laravel 5.1 应用程序部署到 Digital Ocean 上 Ubuntu 上的 LAMP 设置。
在 http://159.203.82.91/ 访问我的 Droplet 让我:
This Works
我设置了 1.0
的路由前缀(见下文),http://159.203.82.91/1.0:
但它应该是
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 ^(.*)/$ / [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>
---
请检查以下几点以解决您的问题。
- 确认您在 Apache 中启用了
mode_rewrite
。 - 确认您在 Apache 虚拟主机配置中放置了
AllowOverride
指令。
Follow this 如果您不知道该怎么做。从指南中,您只需要了解如何启用 mod_rewrite
并编辑您的默认虚拟主机以允许使用 .htaccess
.