2023年2月8日水曜日

apache htaccess

【apache リダイレクト】
# vi /etc/httpd/conf.d/htaccess.conf
<Directory /var/www/html/dirctory>
AllowOverride All
</Directory>

# vi .htaccess
Redirect permanent /元 https://www.world.com/先

【BASIC 認証】
<Directory /var/www/html/dirctory>
AllowOverride All
</Directory>

# cd 対象ディレクト
# vi .htaccess
# authenticate(Basic)
AuthUserFile /var/www/html/portal/doc/.htpasswd  ←本当は、ドキュメント外が望ましい。
AuthGroupFile /dev/null
AuthName "IDとパスワードを入力してください。"
AuthType Basic
require valid-user

# htpasswd -c .htpasswd    user1          # renew
# htpasswd      .htpasswd   user2           # add

# chown apache:apache .htaccess  .htpasswd
# chmod 644 .htaccess
# chmod 644 .htpasswd

【パスワード生成】
$  openssl rand -base64 40 | fold -w 40 | head -1
※ 使用したくない文字がある場合。
$ openssl rand -base64 9 | tr 'il1oO0' '#$%&()'

0 件のコメント:

コメントを投稿

シャットダウン時の後処理 (shutdown)

# vi /etc/systemd/system/drop.service [Unit] Description= stop httpgwd DefaultDependencies=no Before=shutdown.target RefuseManualStart=true ...