0
0

More than 3 years have passed since last update.

Laravelをレンサバ等のサブフォルダで動かす

Last updated at Posted at 2021-05-17

特定のドキュメントルート /home/fooがあるとして
https://xxxxxx/barでlaravel設置したい

でも

/home/foo
     /bar(public)
     /app
     /config

みたいなのを避けたい時用
ググるとapacheのconfいじったりするのは出てきますがレンサバ等では出来ないので
htaccessとプラスアルファで出来る方法の備忘録

まず設置(ディレクトリは省略)

/home/foo
     /bar
       /app
       /config
       /public

/home/bar配下に以下のhtaccess設置

.htaccess
RewriteEngine on
RewriteBase /bar/
RewriteRule ^$ public/ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ public/$1 [L]

これだけですが
route/web.phpに書くときにuriに/barが必要になります

route/web.php
//トップ
Route::match(['get', 'post'],'/bar', 'App\Http\Controllers\TopController@index')->name('top');
//なんか一覧
Route::get('/bar/list', 'App\Http\Controllers\Master\SearchController@list');
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0