{"id":862,"date":"2025-06-05T07:26:23","date_gmt":"2025-06-05T07:26:23","guid":{"rendered":"https:\/\/coru2.com\/blog\/?p=862"},"modified":"2025-06-02T07:42:38","modified_gmt":"2025-06-02T07:42:38","slug":"htaccess%e3%81%a7basic%e8%aa%8d%e8%a8%bc%e3%81%99%e3%82%8b%e6%99%82%e3%81%ab%e6%af%8e%e5%9b%9e%e7%a2%ba%e8%aa%8d%e3%81%99%e3%82%8b%e3%82%84%e3%81%a4%e3%81%ae%e3%83%a1%e3%83%a2","status":"publish","type":"post","link":"https:\/\/coru2.com\/blog\/archives\/862","title":{"rendered":"htaccess\u3067BASIC\u8a8d\u8a3c\u3059\u308b\u6642\u306b\u6bce\u56de\u78ba\u8a8d\u3059\u308b\u3084\u3064\u306e\u30e1\u30e2"},"content":{"rendered":"\n<p>htaccess\u4f7f\u3063\u3066\u7c21\u5358\u306bBASIC\u8a8d\u8a3c\u3059\u308b\u306e\u3001\u305f\u307e\u306b\u3084\u308b\u3068\u3084\u308a\u65b9\u5fd8\u308c\u304c\u3061\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>PHP\u304c\u4f7f\u3048\u308b\u74b0\u5883<\/li>\n\n\n\n<li>BASIC\u8a8d\u8a3c\u304c\u30b5\u30fc\u30d0\u30fc\u7ba1\u7406\u753b\u9762\u4ee5\u5916\u304b\u3089\u3082\u53ef\u80fd\uff08\u3055\u304f\u3089\u30b5\u30fc\u30d0\u30fc\u7b49<\/li>\n<\/ul>\n\n\n\n<p>\u3067\u3042\u308c\u3070\u3001<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4e0b\u8a18\u3092\u8a18\u8ff0\u3057\u305fphp\u3092\u7528\u610f\uff08username\u3068password\u306f\u4efb\u610f\u306e\u3082\u306e)<\/li>\n\n\n\n<li>FTP\u3068\u304b\u3067php\u3092\u8a2d\u7f6e<\/li>\n\n\n\n<li>URL\u306b\u30a2\u30af\u30bb\u30b9<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n$filepath = __FILE__;\n$dirname = dirname($filepath);\n$htpasswd_path = $dirname . '\/.htpasswd';\necho '&lt;pre>AuthUserFile '.$htpasswd_path.\"\\n\";\necho 'AuthGroupFile \/dev\/null'.\"\\n\";\necho 'AuthName \"TEST SITE\"'.\"\\n\";\necho 'AuthType Basic'.\"\\n\";\necho ''.\"\\n\";\necho 'require valid-user'.\"\\n&lt;\/pre>\";\n\n?>\n&lt;?php\n\n$username = 'testuser'; \/\/ \u8a2d\u5b9a\u3057\u305f\u3044\u30e6\u30fc\u30b6\u30fc\u540d\n$password = '1234abcd'; \/\/ \u8a2d\u5b9a\u3057\u305f\u3044\u30d1\u30b9\u30ef\u30fc\u30c9\n\n$hashed_password = password_hash($password, PASSWORD_DEFAULT);\nif ($hashed_password === false) {\n    echo \"\u30d1\u30b9\u30ef\u30fc\u30c9\u30cf\u30c3\u30b7\u30e5\u306e\u751f\u6210\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002\\n\";\n    exit;\n}\n\n$htpasswd_line = $username . ':' . $hashed_password;\n\necho \"# \u4ee5\u4e0b\u3092 .htpasswd \u30d5\u30a1\u30a4\u30eb\u306b\u8a18\u8ff0\u3057\u3066\u304f\u3060\u3055\u3044:\\n&lt;br>\";\necho \"# \".$htpasswd_line . \"\\n\";\n?><\/code><\/pre>\n\n\n\n<p>\u4e0a\u8a18\u3092\u5b9f\u884c\u3059\u308b\u3068\u2193\u304c\u51fa\u529b\u3055\u308c\u308b\u306e\u3067\u3001<br>.htaccess\u306b\u306f<br>AuthUserFile\uff5erequire valid-user\u307e\u3067\u30b3\u30d4\u30da\u3057\u3066<br>.htpasswd\u306b\u306f<br>[\u81ea\u5206\u3067\u8a2d\u5b9a\u3057\u305fuser\u540d]\u4ee5\u964d\u3092\u30b3\u30d4\u30da\u3057\u3066\u3001\u4e21\u65b9\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30c3\u30d7\u3059\u308b\u3068OK\u306a\u306f\u305a\u3002<\/p>\n\n\n\n<pre class=\"wp-block-verse has-sm-lightest-gray-background-color has-background\">AuthUserFile [\u3053\u3053\u304c\u30d5\u30a1\u30a4\u30eb\u30d1\u30b9\u306b\u306a\u3063\u3066\u308b]\/.htpasswd<br>AuthGroupFile \/dev\/null<br>AuthName \"TEST SITE\"<br>AuthType Basic<br><br>require valid-user<br># \u4ee5\u4e0b\u3092 .htpasswd \u30d5\u30a1\u30a4\u30eb\u306b\u8a18\u8ff0\u3057\u3066\u304f\u3060\u3055\u3044:<br># testuser:\u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u6697\u53f7\u5316\u3055\u308c\u305f\u9577\u3044\u6587\u5b57\u5217<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>htaccess\u4f7f\u3063\u3066\u7c21\u5358\u306bBASIC\u8a8d\u8a3c\u3059\u308b\u306e\u3001\u305f\u307e\u306b\u3084\u308b\u3068\u3084\u308a\u65b9\u5fd8\u308c\u304c\u3061\u3002 \u3067\u3042\u308c\u3070\u3001 \u4e0a\u8a18\u3092\u5b9f\u884c\u3059\u308b\u3068\u2193\u304c\u51fa\u529b\u3055\u308c\u308b\u306e\u3067\u3001.htaccess\u306b\u306fAuthUserFile\uff5erequire valid-user\u307e\u3067\u30b3\u30d4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","wp-seo-meta-description":"","wp-seo-meta-robots":[]},"categories":[54],"tags":[],"class_list":{"0":"post-862","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-web","7":"c-entry"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/coru2.com\/blog\/wp-json\/wp\/v2\/posts\/862","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/coru2.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/coru2.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/coru2.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/coru2.com\/blog\/wp-json\/wp\/v2\/comments?post=862"}],"version-history":[{"count":1,"href":"https:\/\/coru2.com\/blog\/wp-json\/wp\/v2\/posts\/862\/revisions"}],"predecessor-version":[{"id":863,"href":"https:\/\/coru2.com\/blog\/wp-json\/wp\/v2\/posts\/862\/revisions\/863"}],"wp:attachment":[{"href":"https:\/\/coru2.com\/blog\/wp-json\/wp\/v2\/media?parent=862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/coru2.com\/blog\/wp-json\/wp\/v2\/categories?post=862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/coru2.com\/blog\/wp-json\/wp\/v2\/tags?post=862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}