Lightsail|WordPress - bitnami|.htaccessを有効化する方法
.htaccessが効かない、動かない、使えない
以前に記載したLightsail|WordPress - bitnami|BASIC認証とDigest認証の設定方法では、
WordPressのファイル群に .htaccess を入れてもダメ
私は普段、wp-adminやwp-login.phpのある階層に.htaccessを置いてBASIC認証をかけていましたが、この方法はAWSのLightsailでは不可のようです。
と記載しました。
WordPress - bitnami においては、デフォルトで.htaccess
が利用不可になっています。
でも、「どうしても.htaccess
使いたいねん」「〜.conf
を変更の度に、いちいち再起動するのがメンドイねん」という方もいらっしゃるのではないでしょうか?
そこで、bitnamiで.htaccessを有効化する方法を記載します。難しくありません。一行を変更するだけです。
まずマニュアルの確認から
bitnami においての.htaccess
ファイルの扱いについては、下記をご参照ください(英語)
Understand Default .Htaccess File Configuration
その中に、下記の記載があります。
One of our main goals is to configure Bitnami applications in the most secure way. For this reason, we moved the configuration in the .htaccess files to the main application configuration files and set the AllowOverride option to None by default, if supported by the application.
(訳)Bitnami アプリケーションを最も安全な方法で設定することを主な目標の一つとしています。このため、.htaccess ファイル内の設定をメインのアプリケーション設定ファイルに移動し、アプリケーションがサポートしている場合は、AllowOverride オプションをデフォルトで None に設定しました。
AllowOverride
オプションをデフォルトで None
にしているので、.htaccess
が使えないというわけです。
.htaccessの有効化|AllowOverride All
- 変更するファイルは
/opt/bitnami/apps/wordpress/conf/httpd-app.conf
です。
- ファイル中の
AllowOverride None
を AllowOverride All
へ変更し保存してください。
/opt/bitnami/apps/wordpress/conf/httpd-app.conf
# 〜省略〜
<Directory "/opt/bitnami/apps/wordpress/htdocs">
Options +MultiViews +FollowSymLinks
# AllowOverride None ← コレ
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
# 〜省略〜
AllowOverride とは
/opt/bitnami/apps/wordpress/conf/httpd-app.conf
です。AllowOverride None
を AllowOverride All
へ変更し保存してください。# 〜省略〜
<Directory "/opt/bitnami/apps/wordpress/htdocs">
Options +MultiViews +FollowSymLinks
# AllowOverride None ← コレ
AllowOverride All
<IfVersion < 2.3 >
Order allow,deny
# 〜省略〜
簡単にいえば、.htaccess
の有効化/無効化です。
AllowOverride All
なら有効で
AllowOverride None
なら無効です。
ちゃんとした解説は...
Apache コア機能 | AllowOverride ディレクティブ
Apacheの再起動
〜.conf
ファイルを触ったあとは、Apacheを再起動します。
$ sudo /opt/bitnami/ctlscript.sh restart apache
これで、bitnamiのWordPressのディレクトリにおいて.htaccess
ファイルも読み込まれるようになりました。
(bitnamiの他のアプリについても、それぞれの〜.conf
ファイルでAllowOverride All
すればOKです)
ただし、あくまでbitnamiの推奨は〜.conf
ファイルへ記載することです。
Some plugins, during their installation, create a .htaccess file in either the /opt/bitnami/apps/APPNAME/htdocs/ or in the /opt/bitnami/apps/APPNAME/htdocs//plugins directory that cannot be read by Apache. For that reason, we recommend moving the content of that file to the /opt/bitnami/apps/APPNAME/conf/htaccess.conf file.
(訳)プラグインによっては、インストール時に /opt/bitnami/apps/APPNAME/htdocs/ または /opt/bitnami/apps/APPNAME/htdocs//plugins ディレクトリのいずれかに .htaccess ファイルが作成され、Apache が読み取れないものがあります。そのため、そのファイルの内容を/opt/bitnami/apps/APPNAME/conf/htaccess.confファイルに移動することをお勧めします。
本稿は以上となります。
Author And Source
この問題について(Lightsail|WordPress - bitnami|.htaccessを有効化する方法), 我々は、より多くの情報をここで見つけました https://qiita.com/tomokei5634/items/51ecd10fa0bd09c5cf60著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .