{"id":2321,"date":"2021-12-25T00:35:38","date_gmt":"2021-12-24T15:35:38","guid":{"rendered":"https:\/\/dennie.tokyo\/it\/?p=2321"},"modified":"2022-03-14T22:27:02","modified_gmt":"2022-03-14T13:27:02","slug":"%e3%80%90apache%e3%80%91-htaccess-%e3%82%92%e6%9c%89%e5%8a%b9%e3%81%ab%e3%81%99%e3%82%8b","status":"publish","type":"post","link":"https:\/\/dennie.tokyo\/it\/?p=2321","title":{"rendered":"\u3010Apache\u3011.htaccess \u3092\u6709\u52b9\u306b\u3059\u308b"},"content":{"rendered":"\n<p>.htaccess \u306f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5358\u4f4d\u3067WEB\u30b5\u30fc\u30d0\u306e\u8a2d\u5b9a\u3092\u5236\u5fa1\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>.htaccess \u306f Apache web \u30b5\u30fc\u30d0\u3067\u306e\u307f\u4f7f\u7528\u53ef\u80fd\u3067\u3001nginx \u306e\u3088\u3046\u306aApache\u4ee5\u5916\u306eweb\u30b5\u30fc\u30d0\u3067\u306f\u4f7f\u7528\u3067\u304d\u307e\u305b\u3093\u3002<br>.htaccess \u306f\u305d\u306e\u307e\u307e\u3067\u306f\u4f7f\u3048\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308b\u306e\u3067\u3001\u4f7f\u3048\u308b\u3088\u3046\u306b\u8a2d\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br>\u4eca\u56de\u306f .htaccess \u3092\u6709\u52b9\u306b\u3059\u308b\u65b9\u6cd5\u306b\u3064\u3044\u3066\u8a18\u8f09\u3057\u307e\u3059\u3002<br>\u306a\u304a\u3001\u4eca\u56de\u306e\u74b0\u5883\u306f\u4ee5\u4e0b\u306b\u306a\u308a\u307e\u3059\u3002 Amazon Linux2 docker \u30b3\u30f3\u30c6\u30ca\u306b\u3066 Apache2.4 \u3092\u4f7f\u7528\u3057\u307e\u3059\u3002 <\/p>\n\n\n\n<div class=\"title_box\"><span class=\"box-title\">\u53c2\u8003<\/span>\n<p><a href=\"https:\/\/dennie.tokyo\/it\/?p=2279\" rel=\"noopener\" target=\"_blank\">\u3010docker\u3011Amazon Linux2 apache \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/a><\/p>\n<\/div>\n\n\n\n<h1 class=\"wp-block-heading\">.htaccess \u3092\u4f7f\u7528\u53ef\u80fd\u306b\u3059\u308b\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u78ba\u8a8d<\/h1>\n\n\n\n<p>Apache\u306f\u5fc5\u8981\u306a\u6a5f\u80fd\u3092\u30e2\u30b8\u30e5\u30fc\u30eb\u3068\u3044\u3046\u5358\u4f4d\u3067\u8aad\u307f\u8fbc\u3093\u3067\u3044\u307e\u3059\u3002<br>mod_rewrite.so \u306f .htaccess \u3092\u6709\u52b9\u306b\u3059\u308b\u70ba\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u3059\u3002<br>Apache\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u3064\u3044\u3066\u306f\u4ee5\u4e0b\u3092\u53c2\u8003\u306b\u3057\u3066\u4e0b\u3055\u3044\u3002<\/p>\n\n\n\n<div class=\"title_box\"><span class=\"box-title\">\u53c2\u8003<\/span><p><a href=\"https:\/\/dennie.tokyo\/it\/?p=2495\" target=\"_blank\" rel=\"noopener\">Apache \u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u3088\u307f\u3053\u307f\u306b\u3064\u3044\u3066<\/a><\/p>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">mod_rewrite.so \u306e\u78ba\u8a8d\u65b9\u6cd5<\/h2>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3067mod_rewrite.so\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u691c\u7d22\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30fb\u30b3\u30de\u30f3\u30c9<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>find \/ -name &#39;mod_rewrite.so&#39;<\/code><\/pre><\/div>\n\n\n\n<p>\u30fb\u7d50\u679c<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>\/usr\/lib64\/httpd\/modules\/mod_rewrite.so<\/code><\/pre><\/div>\n\n\n\n<p>\u306a\u304a\u3001Apache\u304c\u8aad\u307f\u8fbc\u3080\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5834\u6240\u306b\u3064\u3044\u3066\u306f\u3001\u4ee5\u4e0b\u3067\u3082\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"title_box\"><span class=\"box-title\">\u53c2\u8003<\/span>\n<p><a href=\"https:\/\/dennie.tokyo\/it\/?p=2360\" rel=\"noopener\" target=\"_blank\">Apache \u8aad\u307f\u8fbc\u307f\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5834\u6240<\/a><\/p>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">mod_rewrite\u304c\u6709\u52b9\u306b\u306a\u3063\u3066\u3044\u308b\u4e8b\u306e\u78ba\u8a8d<\/h2>\n\n\n\n<p>\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u306fApache\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306b\u8a18\u8f09\u304c\u3042\u308a\u307e\u3059\u3002<br>Amazon Linux2 \u306eApache\u3067\u306f\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306f\u5206\u5272\u3055\u308c\u3066\u3044\u3066\u3001\u30e2\u30b8\u30e5\u30fc\u30eb\u8aad\u307f\u8fbc\u307f\u7528\u306b\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u304c\u3042\u308a\u307e\u3057\u305f\u3002<br>\u81ea\u5206\u306e\u74b0\u5883\u3067\u306f 00-base.conf \u306b mod_rewrite.so \u306e\u8aad\u307f\u8fbc\u307f\u306e\u8a18\u8f09\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u30fb\u30b3\u30de\u30f3\u30c9<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>cat \/etc\/httpd\/conf.modules.d\/00-base.conf<\/code><\/pre><\/div>\n\n\n\n<p>\u30fb\u8a18\u8f09\u5185\u5bb9\u629c\u7c8b<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>LoadModule rewrite_module modules\/mod_rewrite.so<\/code><\/pre><\/div>\n\n\n\n<p>\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3055\u308c\u3066\u3044\u306a\u3051\u308c\u3070mod_rewrite\u304c\u6709\u52b9\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>Apache\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u8aad\u307f\u8fbc\u307f\u306b\u3064\u3044\u3066\u306f\u4ee5\u4e0b\u3092\u53c2\u8003\u306b\u3057\u3066\u4e0b\u3055\u3044\u3002<\/p>\n\n\n\n<div class=\"title_box\"><span class=\"box-title\">\u53c2\u8003<\/span><a href=\"https:\/\/dennie.tokyo\/it\/?p=2495\" target=\"_blank\" rel=\"noopener\">Apache \u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u3088\u307f\u3053\u307f\u306b\u3064\u3044\u3066<\/a>\n<\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u8a2d\u5b9a\u306e\u4e0a\u66f8\u304d\u306e\u8a31\u53ef<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\u8a2d\u5b9a\u306e\u5909\u66f4<\/h2>\n\n\n\n<p>\u4eca\u56de\u306f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30eb\u30fc\u30c8\u3078Apache\u306e\u8a2d\u5b9a\u5909\u66f4\u3092\u8a31\u53ef\u3059\u308b\u8a2d\u5b9a\u3092\u884c\u3044\u307e\u3059\u3002\u306a\u304a\u3001\u81ea\u5206\u306e\u74b0\u5883\u3067\u306f &#8220;\/var\/www\/html&#8221; \u304c\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30eb\u30fc\u30c8\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br>Apache\u306e\u8a2d\u5b9a\u5909\u66f4\u3092\u8a31\u53ef\u3059\u308b\u8a2d\u5b9a\u306f AllowOverride \u30c7\u30a3\u30ec\u30af\u30c6\u30a3\u30d6\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002AllowOverride \u304c &#8220;None&#8221; \u306e\u5834\u5408\u3001&#8221;All&#8221; \u3078\u5909\u66f4\u3057\u307e\u3059\u3002<br>\u3053\u308c\u306f\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea &#8220;\/var\/www\/html&#8221; \u306b\u5bfe\u3057\u3066Apache\u306e\u8a2d\u5b9a\u3092\u4e0a\u66f8\u304d\u53ef\u80fd\u3068\u3059\u308b\u4e8b\u3092\u8a31\u53ef\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<br>\u3053\u3046\u3059\u308b\u3053\u3068\u306b\u3088\u308a\u3001.htaccess \u306e\u8a2d\u5b9a\u5185\u5bb9\u306b\u3088\u3063\u3066Apache\u306e\u8a2d\u5b9a\u3092\u4e0a\u66f8\u304d\u3059\u308b\u3068\u3044\u3046\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002<br>\u4ee5\u4e0b\u306f\u3001Apache\u306e\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30eb\u30fc\u30c8\u306e\u8a2d\u5b9a\u5185\u5bb9\u3092\u629c\u7c8b\u3057\u305f\u3082\u306e\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code># Further relax access to the default document root:\n&lt;Directory &quot;\/var\/www\/html&quot;&gt;\n    #\n    # Possible values for the Options directive are &quot;None&quot;, &quot;All&quot;,\n    # or any combination of:\n    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews\n    #\n    # Note that &quot;MultiViews&quot; must be named *explicitly* --- &quot;Options All&quot;\n    # doesn&#39;t give it to you.\n    #\n    # The Options directive is both complicated and important.  Please see\n    # http:\/\/httpd.apache.org\/docs\/2.4\/mod\/core.html#options\n    # for more information.\n    #\n    Options Indexes FollowSymLinks\n\n    #\n    # AllowOverride controls what directives may be placed in .htaccess files.\n    # It can be &quot;All&quot;, &quot;None&quot;, or any combination of the keywords:\n    #   Options FileInfo AuthConfig Limit\n    #\n    AllowOverride All\n\n    #\n    # Controls who can get stuff from this server.\n    #\n    Require all granted\n&lt;\/Directory&gt;<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Apache\u306e\u8a2d\u5b9a\u8aad\u307f\u8fbc\u307f<\/h2>\n\n\n\n<p>\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb\u3092\u5909\u66f4\u3057\u305f\u3060\u3051\u3067\u306fApache\u306f\u8a2d\u5b9a\u3092\u8aad\u307f\u8fbc\u3093\u3067\u304f\u308c\u307e\u305b\u3093\u3002Apache\u3092\u518d\u8d77\u52d5\u3059\u308b\u3068\u5909\u66f4\u3057\u305f\u8a2d\u5b9a\u3092\u8aad\u307f\u8fbc\u3093\u3067\u304f\u308c\u307e\u3059\u3002<br>\u3086\u3048\u306b\u3001Apache\u3092\u518d\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>systemctl restart httpd<\/code><\/pre><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u52d5\u4f5c\u78ba\u8a8d<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">.htaccess\u306e\u4f5c\u6210<\/h2>\n\n\n\n<p>\u8a66\u3057\u306b\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u30eb\u30fc\u30c8(&#8220;\/var\/www\/html&#8221;)\u3078 .htaccess \u30d5\u30a1\u30a4\u30eb\u3092\u914d\u7f6e\u3057\u52d5\u4f5c\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p>\u30fb\u30b3\u30de\u30f3\u30c9<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>vi \/var\/www\/html\/.htaccess<\/code><\/pre><\/div>\n\n\n\n<p>\u30fb\u5185\u5bb9<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-plain\"><code>RewriteEngine On\nRewriteRule ^test.html$ \/test\/index.html [R,L]<\/code><\/pre><\/div>\n\n\n\n<p>http:\/\/localhost\/test.html\u3078\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001http:\/\/localhost\/test\/index.html\u3078\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u308c\u308b\u3068\u3044\u3046\u8a2d\u5b9a\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u52d5\u4f5c\u78ba\u8a8d\u7528\u30d5\u30a1\u30a4\u30eb\u306e\u4f5c\u6210<\/h2>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3057\u3001\u78ba\u8a8d\u306e\u70ba\u306b\u30d6\u30e9\u30a6\u30b6\u306b\u8868\u793a\u3055\u305b\u308b\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<br>\u5185\u5bb9\u306f \u201ctest\u201d \u3068\u8a00\u3046\u6587\u5b57\u3068\u3057\u307e\u3059\u304c\u5185\u5bb9\u306f\u306a\u3093\u3067\u3082\u826f\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>mkdir \/var\/www\/html\/test\nvi \/var\/www\/html\/test\/index.html<\/code><\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u78ba\u8a8d<\/h2>\n\n\n\n<p>\u30d6\u30e9\u30a6\u30b6\u3078 http:\/\/localhost\/test.html \u3092\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044\u3002 \u201ctest\u201d \u3068\u8868\u793a\u3055\u308c\u308c\u3070\u6210\u529f\u3067\u3059\u3002<br>\u3061\u306a\u307f\u306b\u4eca\u56de\u306f\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u30d6\u30e9\u30a6\u30b6\u306e\u30a2\u30c9\u30ec\u30b9\u30d0\u30fc\u306f http:\/\/localhost\/test\/test.html \u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u6700\u5f8c\u306b<\/h1>\n\n\n\n<p>\u7c21\u5358\u306a\u3088\u3046\u3067\u305d\u3046\u7c21\u5358\u306b\u306f\u3046\u307e\u304f\u3044\u304d\u307e\u305b\u3093\u306d\u3002\u8272\u3005\u8abf\u3079\u3066\u610f\u5473\u3092\u7406\u89e3\u3057\u3066\u3084\u3063\u3068\u51fa\u6765\u305f\u3068\u3044\u3046\u611f\u3058\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>.htaccess \u306f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5358\u4f4d\u3067WEB\u30b5\u30fc\u30d0\u306e\u8a2d\u5b9a\u3092\u5236\u5fa1\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u30d5\u30a1\u30a4\u30eb\u3067\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":968,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-2321","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-apache"],"_links":{"self":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/2321","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2321"}],"version-history":[{"count":35,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/2321\/revisions"}],"predecessor-version":[{"id":3142,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/2321\/revisions\/3142"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/media\/968"}],"wp:attachment":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}