Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPBカップ
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WordPress管理者(wp-admin)ディレクトリをパスワードで保護する方法

編集メモ: WPBeginner のパートナーリンクから手数料を得ています。手数料は編集者の意見や評価に影響を与えません。編集プロセスについて詳しく知る。

WordPressの管理ディレクトリをパスワードで保護する方法を知りたいですか?

WordPressの管理ディレクトリにパスワード保護を追加することで、WordPressのセキュリティを向上させることができます。

この投稿では、wp-adminディレクトリを簡単にパスワードで保護する方法について説明します。

How to Password Protect Your WordPress Admin (wp-admin) Directory

WordPress管理ディレクトリをパスワードで保護する理由

WordPress の管理ディレクトリをパスワードで保護することで、WordPress サイトの最も重要なエントリポイントにセキュリティのレイヤーを追加できます。

WordPressの管理ダッシュボードは、あなたのサイトの中心的なハブです。投稿やページの公開、テーマのカスタマイズ、WordPressプラグインのインストールなどを行う場所です。

ハッカーがあなたのサイトに侵入しようとする場合、ブルートフォースアタックを使ってwp-admin画面から行うことがよくあります。

強力なパスワードや ログイン試行の制限などのセキュリティ対策を行うことで、潜在的な攻撃からサイトを保護することができます。

さらに安全性を高めるために、wp-adminディレクトリをパスワードで保護することもできます。そうすれば、誰かがあなたの管理エリアにアクセスしようとしたとき、WordPressのログインページにたどり着く前にユーザー名とパスワードを入力する必要があります。

それでは、WordPressの管理ディレクトリをパスワードで保護する方法を順を追って見ていきましょう。

ほとんどのユーザーには最初の方法が推奨されており、以下のクイックリンクから使いたい方法に直接飛ぶことができる:

動画チュートリアル

Subscribe to WPBeginner

もし、文章での説明がお望みなら、このまま読み進めてほしい。

方法1: ディレクトリプライバシーを使用してwp-adminをパスワードで保護する(推奨)

WordPressの管理ディレクトリをパスワードで保護する最も簡単な方法は、WordPressホスティングサービスのDirectory Privacyアプリを使用することです。

まず、ホスティングアカウントのダッシュボードにログインし、ウェブサイトのcPanelダッシュボードのファイルセクションにある「ディレクトリのプライバシー」オプションをクリックする必要があります。

Click on the Directory Privacy option in the Files section

注: BluehostのようなcPanelを使用しているほとんどのホスティングサービスでは、同様の手順があります。ただし、ホスティングサービスによっては、ダッシュボードがスクリーンショットと若干異なる場合があります。

サーバー上のすべてのディレクトリを一覧表示する画面が表示されます。あなたのサイトのファイルを含むフォルダーを見つける必要があります。

ほとんどのサイトオーナーにとって、これは「public_html」フォルダーをクリックすることで見つけることができる。

Click public_html

サーバーにインストールしたサイトファイルがすべて表示されます。

次に、あなたのサイトのドメイン名のフォルダーをクリックする必要があります。

Click domain name folder

そのフォルダーの中にwp-adminフォルダーがあります。

フォルダー名をクリックする代わりに、そのフォルダーの横にある「編集」ボタンをクリックする必要があります。

Click edit wp-admin folder

パスワード保護をオンにする画面が表示されます。

このディレクトリをパスワードで保護する」というボックスにチェックを入れるだけです。お好みで、ディレクトリに’Admin Area’のような名前をつけることもできます。

Check password protect directory box

それが済んだら、『保存』ボタンをクリックしてください。

確認メッセージが表示されるページに移動します。

Confirmation message click back button

Go Back’ボタンをクリックすると、このディレクトリにアクセスできるユーザーを作成する画面になります。

ユーザー名とパスワードを入力し、パスワードを確認するよう求められます。ユーザー名とパスワードは、パスワード管理アプリなど安全な場所に控えておいてください。

Create a User

本当に〜してもよいですか?

これで、誰かがあなたの wp-admin ディレクトリにアクセスしようとすると、上記で作成したユーザー名とパスワードを入力するよう求められます。

Password protect WordPress admin example

方法2:コードを使ってwp-adminをパスワードで保護する

WordPressの管理ディレクトリを手動でパスワード保護することもできます。そのためには、.htpasswdと .htaccessという2つのファイルを作成する必要があります。

注意:WordPressサイトにコードを追加することは危険です。小さなミスでも、サイトに大きなエラーを引き起こす可能性があります。この方法は上級ユーザーにのみお勧めします。

.htaccessファイルの作成

まず、お好みのテキストエディターを開き、新しいファイルの名前を.htaccessとします。

その後、以下のコード・スニペットをコピーしてファイルに追加する必要がある:

AuthName "Admins Only"
AuthUserFile /home/user/public_html/example.com/wp-admin/.htpasswd
AuthGroupFile /dev/null
AuthType basic
require user yourusername

AuthUserFile’のパスを.htpasswdファイルをアップロードする場所に変更し、’yusername’をログイン中に使用するユーザー名に変更することを本当に〜してもよいですか?

終了したらファイルを保存することをお忘れなく。

.htpasswdファイルの作成

それができたら、.htpasswdファイルを作成する必要がある。

これを行うには、テキストエディターを開き、.htpasswdというファイルを作成します。このファイルには、ユーザー名とパスワードが暗号化された形式で記載されます。

暗号化されたパスワードを生成する最も簡単な方法は、htpasswdジェネレータを使うことです。

ユーザー名とパスワードを入力し、暗号化形式を選択して「.htpasswdファイルを作成」ボタンをクリックするだけです。

Create htpasswd file

htpasswdジェネレータは、あなたが.htpasswdファイルに貼り付ける必要があるテキストの行を表示します。ファイルを保存したら、本当に〜してもよいですか?

wp-adminディレクトリへの.htaccessと.htpasswdのアップダー

最後のステップは、作成した両方のファイルをサイトのwp-adminフォルダにアップロードすることです。

FTPクライアントまたはホスティングサービスプロバイダーが提供するオンラインファイルマネージャツールを使用して、WordPressホスティングアカウントに接続する必要があります。詳細については、WordPressにファイルをアップロードするためのFTPの使用方法についての初心者ガイドを参照してください。

このチュートリアルでは、無料でMacでもWindowsでも使えるFileZillaを使います。

サイトに接続すると、左側のウィンドウにコンピューター上のファイル、右側にサイト上のファイルが表示されます。左側で、.htaccessと .htpasswdファイルを保存した場所にナビゲーションする必要があります。

次に、右側にある、保護したいサイトのwp-adminディレクトリに移動する必要があります。ほとんどのユーザーは、public_htmlフォルダーをダブルクリックし、次に自分のドメイン名のフォルダーをダブルクリックし、次にwp-adminフォルダーをダブルクリックする必要があります。

左側の2つのファイルを選択し、右クリックメニューから「アップロード」をクリックするか、左側のウィンドウにファイルをドラッグします。

Uploading the Files to Your Website's wp-admin Directory

これで「wp-admin」ディレクトリがパスワードで保護されます。

wp-adminパスワード保護のトラブルシューティング

サーバーやサイトの設定によっては、WordPressのエラーに遭遇する可能性があります。これらのエラーは、.htaccessファイルに慎重にコードを追加することで修正できます。

注意:これはメインサイトフォルダにある.htaccessファイルで、’wp-admin’ フォルダーにアップロードしたものではありません。.htaccessが見つからない場合は、.htaccessが見つからない理由と見つける方法をご覧ください。

Ajaxが動作しないエラーの修正

最も一般的なエラーの1つは、サイトのフロントエンドでAjax機能が動作しなくなることです。ライブAjax検索や Ajaxお問い合わせフォームなど、Ajaxを必須とするWordPressプラグインを使用している場合、これらのプラグインが動作しなくなることに気づくでしょう。

これを修正するには、wp-adminフォルダーにある.htaccessファイルに以下のコードを追加するだけです:

<Files admin-ajax.php>
    Order allow,deny
    Allow from all
    Satisfy any 
</Files>

404エラーと多すぎるリダイレクトエラーの修正

他に遭遇する可能性のあるエラーは、404エラーと リダイレクトが多すぎるエラーです。

これらを修正する最も簡単な方法は、サイトディレクトリにあるメインの.htaccessファイルを開き、WordPressルールの前に以下のコード行を追加することです:

ErrorDocument 401 default

ボーナス:wp-adminセキュリティのためのベストWordPressガイド

wp-adminディレクトリをパスワードで保護する方法はおわかりいただけたと思いますが、管理エリアをよりセキュアにするためのガイドをご覧ください:

この投稿がWordPressの管理(wp-admin)ディレクトリをパスワードで保護する方法を学ぶのにお役に立てば幸いです。また、無料メールドメインの取得方法や、専門家が選ぶ中小企業に最適なメールマーケティングサービスもご覧ください。

If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.

情報開示 私たちのコンテンツは読者支援型です。これは、あなたが私たちのリンクの一部をクリックした場合、私たちはコミッションを得ることができることを意味します。 WPBeginnerの資金源 をご覧ください。3$編集プロセスをご覧ください。

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

究極のWordPressツールキット

ツールキットへの無料アクセス - すべてのプロフェッショナルが持つべきWordPress関連製品とリソースのコレクション!

Reader Interactions

204件のコメント返信を残す

  1. Syed Balkhi says

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Mrteesurez says

    Thanks. I found it helpful.
    I want to ask if the methods are all offering the same level of security, I would prefer and recommend to stick to the first method as it seems easy and straight forward.

    Or is there any one that is better than the other ??

    • WPBeginner Support says

      These are different methods to achieve the same result so it would depend on your preference for which one you would use.

      管理者

  3. Mark says

    Is there anyway for hackers to gain access to this password and even change it, like in phpMyAdmin ?

    • WPBeginner Support says

      They would need access to your hosting provider or site files for this guide.

      管理者

  4. Salman says

    I have changed my login URL using the “WPS Hide Login” plugin. Lets say the previous URL ended in wp-admin/ and the new URL ends in hidden/ now how can I password protect this new URL?

    • WPBeginner Support says

      It would depend on what method you are using and how you changed the URL, as long as there is a file/folder in the new location you should be able to select that folder or change the path on line 2 of the htaccess method :)

      管理者

    • Jiří Vaněk says

      WPShide doesn’t create a new folder, I use that too. The wp-admin folder is still on the server and functional. So if you use WPSHide, secure the wp-admin folder exactly the same.

  5. Jiří Vaněk says

    A good practice is also to rename the WordPress administration URL and choose a different administrator username than ‘admin.’ Changing the URL makes it harder for attackers to locate the administration, and not using ‘admin’ as the administrator reduces the risk of a successful brute force attack.

    • WPBeginner Support says

      Having a username other than admin is definitely recommended but for changing the wp-admin url is not always recommended as that can cause trouble with some plugins as well as make troubleshooting more difficult.

      管理者

  6. Umer Yaseen says

    What if someone accesses our WordPress admin directory by entering mywebsite.com/wp-login.php instead of mywebsite.com/wp-admin. This method only protects wp-admin and not protects wp-login.php. So how it is useful?

    • WPBeginner Support says

      We’ll see if we can add a method for that type of server when we update this article :)

      管理者

  7. Rajah says

    The first method through cPanel worked like a charm. However, when I logout again from WP and login again it doesn’t ask again for the directory password. Is it meant to ask only once?

    • WPBeginner Support says

      Your cookies/cache will remember the login information. Normally the next time you start up your computer it will require you to log in again.

      管理者

  8. Izzy says

    The “Password Protect Directories” is not on my cPanel under “securitiy”, so I tried the manual way, but it doesn’t seem to work as it doesn’t ask for login when I open wp-admin…

    • WPBeginner Support says

      If you reach out to your hosting provider they should be able to assist and take a look if there’s any reason it wouldn’t be working.

      管理者

  9. Ahsan Ali says

    Thanks for your efforts!
    I used cpanel method it works fine but the problem is that the password prompt appearing on every page of my website!

    What i have to do so that it appear only at wp-admin page?

    • WPBeginner Support says

      It sounds like you may have password protected your public_html folder instead of the wp-admin folder. You would want to remove the current protection and attempt to set it up again

      管理者

返信を残す

コメントありがとうございます。すべてのコメントは私たちのコメントポリシーに従ってモデレートされ、あなたのメールアドレスが公開されることはありませんのでご留意ください。名前欄にキーワードを使用しないでください。個人的で有意義な会話をしましょう。