![](/img/trans.png)
[英]nginx, install laravel in main website sub directory, shows blank page
[英]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.