0
0

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 3 years have passed since last update.

【WordPress】wp-login.php へのアクセスを禁止してブラウザからログインできなくする方法

Last updated at Posted at 2021-11-14

ブラウザを使わない代替のログイン手段を用意する

↓個人的におすすめなのはこれ

aaemnnosttv/wp-cli-login-command: Log in to WordPress with secure passwordless magic links.
https://github.com/aaemnnosttv/wp-cli-login-command

WP-CLI を使ったログイン方法で,ターミナル上でコマンドを打つことでログイン用のワンタイムURLを発行できる.

wp-login.php へのアクセスを禁止する (nginx)

nginxのサイトの設定ファイル (Ubuntu: /etc/nginx/sites-available) に以下を追記.
location /等よりも上に書いた方が良い.

※環境に応じて記述は書き換えてください.

# deny access to wp-login.php (without logout)
if ($request_uri !~* /wp-login\.php\?action=logout ){
  rewrite ^/wp-login\.php(.*)$ /? redirect;
}

wp-login.php へのアクセスを禁止する (apache)

.htaccessに以下を追記.

※環境に応じて記述は書き換えてください.

<IfModule mod_rewrite.c>
RewriteCond %{QUERY_STRING} !^action=logout
RewriteRule  ^wp-login\.php index.php? [R=302,L]
</IfModule>
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?