繁体   English   中英

是否可以仅在子目录中安装lumen或laravel

[英]Is it possible to install lumen or laravel only in a sub directory

我有一个现有的网站\\应用程序。 我想在子目录(例如/api/使用lumen创建JSON API。

如何仅在网站的子目录中安装lumen或laravel?

尝试在apache conf(virtualhost)中使用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中更改以下行:from $app->run(); $app->run($app->make('request'));

使用“ .htaccess”重定向请求(如果无法修改apache conf):

RewriteRule ^api/(.*)$ /api/public/$1 [L]

在您的app / Http / router.php中使用带有前缀的Group删除子文件夹:

$app->group(['prefix' => 'api'], function () use ($app) {
  $app->get('/', function () use ($app) {
      return $app->version();
  });
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM