![](/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.