ちょっときになったのですが、外部サイトに対して.htaccess
をダウンロードしようとしています?
普通、設定しない限りhttp://ドメイン/.htaccess
のようにダウンロードすることはできません。
Apache2.2系であれば下記のように設定されていると思います。
apache
1<FilesMatch "^\.ht">
2 Order allow,deny
3 Deny from all
4 Satisfy All
5</FilesMatch>
上記のような設定を無効にしない限り、下記のようなwget
コマンドでダウンロードすることはできません。
bash
1wget 'http://ドメイン/.htaccess'
「.ht」ファイルをアクセス可能にしている場合は、PHP上では下記のようにします。
php.ini
の下記設定を確認します。
HTMLは例えば、下記のように(index.html
)します。
html
1<form action="getinfo.php" method="get">
2 <input type="button" name="show_ip_address" value="1" />
3 <input type="button" name="gethtaccess" value="1" />
4</form>
そして、PHPは例えば、下記のように(getinfo.php
)します。
php
1<?php
2if (! empty($_POST['gethtaccess'])) {
3 $htaccess = file_get_contents('http://ドメイン/.htaccess');
4 file_put_contents('保存ファイルパス', $htaccess);
5}
6?>