LoginSignup
3
5

More than 5 years have passed since last update.

.NET環境でApacheの.htaccessと同じ処理をする方法

Last updated at Posted at 2014-07-27

最近Microsoftさんとおつきあいさせていただく事があり、サーバ環境等を提供してくださる機会があるので、自分なりにいろいろと試して多くの方に使っていただけるように。

  • Azureで環境を構築している人向け
  • AzureにWordpressが設置されている事を前提
  • 例としてWordpressの.htaccessと同じ事を実践
  • 特定のIPアドレスしかwp-adminにアクセスできないようにする

.NETについて

.NET Frameworkとは

  • 正式名称はMicrosoft .NET Framework(マイクロソフト ドットネット フレームワーク)
  • Microsoft .NET対応アプリケーションの動作環境。
  • Java仮想マシンに近い性格を持つらしい。

Wikipediaを参照

Windows Azureは .NET Frameworkで構成

Screen Shot 2014-07-27 at 12.22.58 PM.png

このように.NETで構成されているのが確認できる。

Apacheの.htaccessと同じ処理をする

Apacheの場合

Apacheの場合は、特定のIPからしかアクセスさせたくないディレクトリに.htaccessを設置します。内容は以下のような感じ。

<Files "wp-login.php">
order deny,allow
deny from all
allow from xxx.xxx.xxx.xxx
</Files>

.NETの場合

.NETの場合は、「web.config」と呼ばれるファイルを対象のディレクトリ内におきます。
XMLで記述します。
XXXの部分が許可するIPアドレスです。

web.confing
<?xml version="1.0" encoding="UTF-8"?>
  <configuration>
    <system.webServer>
      <security>
          <ipSecurity allowUnlisted="false" denyAction="NotFound">
            <add allowed="true" ipAddress="xxx.xxx.xxx.xxx" />
          </ipSecurity>
      </security>
    </system.webServer>
  </configuration>

例えばこれを、
site/wwwroot/wpadmin
に設置すれば、管理画面のログインを特定のIPからのみアクセスするように設定する事が出来ます。

もし、AzureのGUI上でWordpressを設置している場合、
wwwroot/
ディレクトリ内に規定のweb.configがデフォルトで設置されているので、確認してみてください。

3
5
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
3
5