1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Laravel】Herokuでベーシック認証をかける

Last updated at Posted at 2020-03-11

環境

  • Laravel Framework 6.14.0

結論

アプリケーションに.htaccessファイル.htpasswdファイルを含めてgit pushします。
.htaccessファイルについては既に存在しているため、ベーシック認証の設定を追記します。
.htpasswdのパスですが、Herokuではアプリケーションディレクトリが/appとなるため、アプリケーション直下にファイルを作った場合、/app/.htpasswdで参照できます。

/public/.htaccess

AuthUserFile /app/.htpasswd
AuthType Basic
AuthName "Restricted Access"
Require valid-user


/.htpasswd

# test:test
test:NcOjoYwcay98.

ルートディレクトリの根拠


$ heroku run bash
~ $ pwd
/app
~ $ ls
Procfile   artisan	  composer.lock  package.json  resources   storage  webpack.mix.js
README.md  bootstrap	  config	 phpunit.xml   routes	   tests
app	   composer.json  database	 public        server.php  vendor

関連記事

【Laravel】HerokuでHTTPSを強制しつつベーシック認証をかける
https://qiita.com/hiro-chika/items/004eecf6f2ebae94e709

1
4
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
1
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?