是否可以仅在子目录中安装 lumen 或 laravel
Is it possible to install lumen or laravel only in a sub directory
我有一个现有的 website\application。我想在子目录中使用 lumen 创建一个 JSON API——类似于 /api/
.
如何仅在网站的子目录中安装 lumen 或 laravel?
尝试在您的 apache conf(虚拟主机)中使用 Alias:
Alias /api /path/to/api/public
<Directory /path/to/api/public>
Allowoverride All
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
此外,由于从子目录使用 Lumen 时路径错误,您需要在 Lumens public/index.php 中更改以下行:
从 $app->run();
到 $app->run($app->make('request'));
使用“.htaccess”重定向请求(如果您不能修改 apache conf):
RewriteRule ^api/(.*)$ /api/public/ [L]
在您的 app/Http/router.php 中使用带有前缀的组来删除子文件夹:
$app->group(['prefix' => 'api'], function () use ($app) {
$app->get('/', function () use ($app) {
return $app->version();
});
});
我有一个现有的 website\application。我想在子目录中使用 lumen 创建一个 JSON API——类似于 /api/
.
如何仅在网站的子目录中安装 lumen 或 laravel?
尝试在您的 apache conf(虚拟主机)中使用 Alias:
Alias /api /path/to/api/public
<Directory /path/to/api/public>
Allowoverride All
Options Indexes FollowSymLinks Includes
Order allow,deny
Allow from all
</Directory>
此外,由于从子目录使用 Lumen 时路径错误,您需要在 Lumens public/index.php 中更改以下行:
从 $app->run();
到 $app->run($app->make('request'));
使用“.htaccess”重定向请求(如果您不能修改 apache conf):
RewriteRule ^api/(.*)$ /api/public/ [L]
在您的 app/Http/router.php 中使用带有前缀的组来删除子文件夹:
$app->group(['prefix' => 'api'], function () use ($app) {
$app->get('/', function () use ($app) {
return $app->version();
});
});