<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>Htaccess on qwerty.work</title>
        <link>https://qwerty.work/tags/htaccess/</link>
        <description>Recent content in Htaccess on qwerty.work</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>ja-JP</language>
        <lastBuildDate>Tue, 29 Nov 2022 00:00:00 +0000</lastBuildDate><atom:link href="https://qwerty.work/tags/htaccess/index.xml" rel="self" type="application/rss+xml" /><item>
            <title>.htaccessでRainloopのdataフォルダにアクセス制限をかける方法</title>
            <link>https://qwerty.work/post/2022/11/htaccess%E3%81%A7rainloop%E3%81%AEdata%E3%83%95%E3%82%A9%E3%83%AB%E3%83%80%E3%81%AB%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E5%88%B6%E9%99%90%E3%82%92%E3%81%8B%E3%81%91%E3%82%8B%E6%96%B9%E6%B3%95/</link>
            <pubDate>Tue, 29 Nov 2022 00:00:00 +0000</pubDate>
            <guid>https://qwerty.work/post/2022/11/htaccess%E3%81%A7rainloop%E3%81%AEdata%E3%83%95%E3%82%A9%E3%83%AB%E3%83%80%E3%81%AB%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E5%88%B6%E9%99%90%E3%82%92%E3%81%8B%E3%81%91%E3%82%8B%E6%96%B9%E6%B3%95/</guid>
            <description>&lt;h2 id=&#34;管理画面のエラーに対処&#34;&gt;管理画面のエラーに対処&#xA;&lt;/h2&gt;&lt;p&gt;レンタルサーバーに設置できるWEBメーラー「&lt;a class=&#34;link&#34; href=&#34;https://www.rainloop.net/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;Rainloop&lt;/a&gt;」を使用しているのですが、管理画面で以下のようなエラーが出ました。この警告が出ないように対処する方法をメモ。&lt;/p&gt;&#xA;&lt;figure&gt;&#xA;&lt;p&gt;&lt;img class=&#34;gallery-image&#34; data-flex-basis=&#34;1225px&#34; data-flex-grow=&#34;510&#34; height=&#34;148&#34; loading=&#34;lazy&#34; sizes=&#34;(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px&#34; src=&#34;https://qwerty.work/post/2022/11/htaccess%E3%81%A7rainloop%E3%81%AEdata%E3%83%95%E3%82%A9%E3%83%AB%E3%83%80%E3%81%AB%E3%82%A2%E3%82%AF%E3%82%BB%E3%82%B9%E5%88%B6%E9%99%90%E3%82%92%E3%81%8B%E3%81%91%E3%82%8B%E6%96%B9%E6%B3%95/images/RainLoop-warning.png&#34; width=&#34;756&#34;&gt;&lt;/p&gt;&#xA;&lt;figcaption&gt;&#xA;&lt;p&gt;Rainloopの管理画面に表示された警告&lt;/p&gt;&#xA;&lt;/figcaption&gt;&#xA;&lt;/figure&gt;&#xA;&lt;h2 id=&#34;htaccessでディレクトリにアクセス制限&#34;&gt;.htaccessでディレクトリにアクセス制限&#xA;&lt;/h2&gt;&lt;p&gt;Rainloopのディレクトリに&lt;strong&gt;dataフォルダ&lt;/strong&gt;があります。この直下にある**.htaccess**を開いて以下のように変更しります。&lt;/p&gt;&#xA;&lt;h3 id=&#34;変更前のhtaccess&#34;&gt;変更前の.htaccess&#xA;&lt;/h3&gt;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Deny from all&#xA;&amp;lt;IfModule mod_autoindex.c&amp;gt;&#xA;Options -Indexes&#xA;&amp;lt;/ifModule&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;変更後のhtaccess&#34;&gt;変更後の.htaccess&#xA;&lt;/h3&gt;&lt;p&gt;内部からのアクセスは許可して、それ以外はブロックする内容です。&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;SetEnvIf Referer &amp;#34;^https://example.com&amp;#34; chk_url&#xA;SetEnvIf Referer &amp;#34;^http://example.com&amp;#34; chk_url&#xA;&#xA;Order Deny,Allow&#xA;Deny from all&#xA;Allow from env=chk_url&#xA;&#xA;&amp;lt;IfModule mod_autoindex.c&amp;gt;&#xA;Options -Indexes&#xA;&amp;lt;/ifModule&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;これで警告画面がが表示されなくなりました。&lt;/p&gt;&#xA;</description>
        </item><item>
            <title>.htaccessの書き方のお手本・参考・サンプル</title>
            <link>https://qwerty.work/post/2021/12/htaccess_1/</link>
            <pubDate>Mon, 13 Dec 2021 09:37:06 +0900</pubDate>
            <guid>https://qwerty.work/post/2021/12/htaccess_1/</guid>
            <description>&lt;h2 id=&#34;定番の書き方の参考&#34;&gt;定番の書き方の参考&#xA;&lt;/h2&gt;&lt;p&gt;サイトの読み込みスピードを上げるためにApatchだと、&lt;code&gt;.htaccess&lt;/code&gt;にファイル圧縮やキャッシュ期間を設定しなければなりませんが、お手本になるもを見つけたのでメモ。&lt;/p&gt;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;  &#xA;&#xA;&#xA;&lt;div class=&#34;link-card&#34;&gt;&#xA;  &lt;a href=&#34;https://qiita.com/shotets/items/a5465fb41623cc3dae94&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&#xA;    &#xA;    &lt;div class=&#34;link-card-image&#34;&gt;&#xA;      &lt;img src=&#34;https://image.thum.io/get/width/300/crop/200/https://qiita.com/shotets/items/a5465fb41623cc3dae94&#34; alt=&#34;https://qiita.com/shotets/items/a5465fb41623cc3dae94&#34; loading=&#34;lazy&#34;&gt;&#xA;    &lt;/div&gt;&#xA;    &#xA;    &lt;div class=&#34;link-card-body&#34;&gt;&#xA;      &lt;span class=&#34;link-card-title&#34;&gt;https://qiita.com/shotets/items/a5465fb41623cc3dae94&lt;/span&gt;&#xA;      &#xA;      &lt;span class=&#34;link-card-url&#34;&gt;https://qiita.com/shotets/items/a5465fb41623cc3dae94&lt;/span&gt;&#xA;    &lt;/div&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/div&gt;&#xA;&#xA;</description>
        </item><item>
            <title>MovableTypeの管理画面でblank.htmlのダウンロードが開始されるとき</title>
            <link>https://qwerty.work/post/2018/05/movabletype-blankhtml-htaccess/</link>
            <pubDate>Wed, 30 May 2018 11:18:15 +0900</pubDate>
            <guid>https://qwerty.work/post/2018/05/movabletype-blankhtml-htaccess/</guid>
            <description>&lt;h3 id=&#34;管理画面でblankhtmlのダウンロードが始まる&#34;&gt;管理画面でblank.htmlのダウンロードが始まる&#xA;&lt;/h3&gt;&lt;p&gt;レンタルサーバーを &lt;a class=&#34;link&#34; href=&#34;https://px.a8.net/svt/ejp?a8mat=2ZF6W2&amp;#43;2DQFW2&amp;#43;3JTE&amp;#43;5YJRM&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;Mixhost&lt;/a&gt; に引越して以来、 &lt;strong&gt;Internet Explorer（IE）&lt;/strong&gt; でMovable Typeの管理画面にログオンすると &lt;strong&gt;「blank.htmlを保存しますか？」&lt;/strong&gt; と毎回** blank.html **のダウンロードが始まるようになりました。 &lt;strong&gt;Edge&lt;/strong&gt; と &lt;strong&gt;Chrome&lt;/strong&gt; ではこの症状は出ませんでした。&lt;/p&gt;&#xA;&lt;p&gt;&lt;img alt=&#34;balank.htmlを保存しますか？&#34; class=&#34;gallery-image&#34; data-flex-basis=&#34;1230px&#34; data-flex-grow=&#34;512&#34; height=&#34;117&#34; loading=&#34;lazy&#34; sizes=&#34;(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px&#34; src=&#34;https://qwerty.work/post/2018/05/movabletype-blankhtml-htaccess/images/00.jpg&#34; width=&#34;600&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;ちなみに blank.html というファイルはサイト内に存在していません。&lt;/p&gt;&#xA;&lt;h3 id=&#34;原因はhtaccessの１行&#34;&gt;原因は.htaccessの１行&#xA;&lt;/h3&gt;&lt;p&gt;理屈はよくわかりませんが、原因は .htaccess でした。 .htaccess は移行元のものをそのまま移行先の &lt;a class=&#34;link&#34; href=&#34;https://px.a8.net/svt/ejp?a8mat=2ZF6W2&amp;#43;2DQFW2&amp;#43;3JTE&amp;#43;5YJRM&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;Mixhost&lt;/a&gt; で使っていました。その中の以下2行を削除でもよかったのですが、行の先頭に &lt;strong&gt;#&lt;/strong&gt; を入れてコメントアウトしたらダウンロードの画面は出ることがなくなりました。&lt;/p&gt;&#xA;&lt;p&gt;htm、htmlでSSI（サーバーサイドインクルード）を使用できるようにするものらしいです。以前、SSIのテストを行ったときの名残で残していましたが、PHP以外でインクルードを使うことがないので、 &lt;strong&gt;#&lt;/strong&gt; でコメントアウトしました。&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;AddHandler server-parsed .htm .html&#xA;AddType text/x-server-parsed-html .html&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;https://www.screamo.jp/2009/09/07/22/22/27/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;参考にしたページ&lt;/a&gt;では以下の行を削除したとありましたが、私の.htaccessにはこの記載はありませんでしたが、症状が発生したので上記2行はコメントアウトしました。&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;AddType application/x-httpd-php .htm .html .cgi&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;参考ページ&#34;&gt;参考ページ&#xA;&lt;/h3&gt;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;  &#xA;&#xA;&#xA;&lt;div class=&#34;link-card&#34;&gt;&#xA;  &lt;a href=&#34;https://www.screamo.jp/2009/09/07/22/22/27/&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&#xA;    &#xA;    &lt;div class=&#34;link-card-image&#34;&gt;&#xA;      &lt;img src=&#34;https://image.thum.io/get/width/300/crop/200/https://www.screamo.jp/2009/09/07/22/22/27/&#34; alt=&#34;https://www.screamo.jp/2009/09/07/22/22/27/&#34; loading=&#34;lazy&#34;&gt;&#xA;    &lt;/div&gt;&#xA;    &#xA;    &lt;div class=&#34;link-card-body&#34;&gt;&#xA;      &lt;span class=&#34;link-card-title&#34;&gt;https://www.screamo.jp/2009/09/07/22/22/27/&lt;/span&gt;&#xA;      &#xA;      &lt;span class=&#34;link-card-url&#34;&gt;https://www.screamo.jp/2009/09/07/22/22/27/&lt;/span&gt;&#xA;    &lt;/div&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/div&gt;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;&#xA;  &#xA;&#xA;&#xA;&lt;div class=&#34;link-card&#34;&gt;&#xA;  &lt;a href=&#34;https://wordpress.matometa.net/archives/20121009183042&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;&#xA;    &#xA;    &lt;div class=&#34;link-card-image&#34;&gt;&#xA;      &lt;img src=&#34;https://image.thum.io/get/width/300/crop/200/https://wordpress.matometa.net/archives/20121009183042&#34; alt=&#34;https://wordpress.matometa.net/archives/20121009183042&#34; loading=&#34;lazy&#34;&gt;&#xA;    &lt;/div&gt;&#xA;    &#xA;    &lt;div class=&#34;link-card-body&#34;&gt;&#xA;      &lt;span class=&#34;link-card-title&#34;&gt;https://wordpress.matometa.net/archives/20121009183042&lt;/span&gt;&#xA;      &#xA;      &lt;span class=&#34;link-card-url&#34;&gt;https://wordpress.matometa.net/archives/20121009183042&lt;/span&gt;&#xA;    &lt;/div&gt;&#xA;  &lt;/a&gt;&#xA;&lt;/div&gt;&#xA;&#xA;</description>
        </item><item>
            <title>MixHostでphpinfoが403エラーになる原因は.htaccessだった</title>
            <link>https://qwerty.work/post/2018/04/mixhost-phpinfo-403-htaccess/</link>
            <pubDate>Fri, 27 Apr 2018 20:07:26 +0900</pubDate>
            <guid>https://qwerty.work/post/2018/04/mixhost-phpinfo-403-htaccess/</guid>
            <description>&lt;p&gt;レンタルサーバーを&lt;a class=&#34;link&#34; href=&#34;https://px.a8.net/svt/ejp?a8mat=2ZF6W2&amp;#43;2DQFW2&amp;#43;3JTE&amp;#43;5YJRM&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;MixHost&lt;/a&gt;に乗り換えました。&lt;/p&gt;&#xA;&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;https://px.a8.net/svt/ejp?a8mat=2ZF6W2&amp;#43;2DQGNU&amp;#43;3JTE&amp;#43;5ZU29&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;&#xA;&lt;/a&gt;&lt;/p&gt;&#xA;&lt;p&gt;旧サーバーからファイルを&lt;a class=&#34;link&#34; href=&#34;https://px.a8.net/svt/ejp?a8mat=2ZF6W2&amp;#43;2DQFW2&amp;#43;3JTE&amp;#43;5YJRM&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;MixHost&lt;/a&gt;にコピーして****を表示しようとしたら403エラー…。&lt;/p&gt;&#xA;&lt;p&gt;&lt;img class=&#34;gallery-image&#34; data-flex-basis=&#34;349px&#34; data-flex-grow=&#34;145&#34; height=&#34;412&#34; loading=&#34;lazy&#34; sizes=&#34;(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px&#34; src=&#34;https://qwerty.work/post/2018/04/mixhost-phpinfo-403-htaccess/images/No-00.jpg&#34; width=&#34;600&#34;&gt;&lt;/p&gt;&#xA;&lt;h3 id=&#34;htaccessとcpanelでphpのバージョンが相違していたのが原因&#34;&gt;.htaccessとcPanelでPHPのバージョンが相違していたのが原因&#xA;&lt;/h3&gt;&lt;p&gt;旧サーバーでは.htaccessに以下の記載がないとPHPは動きませんでした。&lt;a class=&#34;link&#34; href=&#34;https://px.a8.net/svt/ejp?a8mat=2ZF6W2&amp;#43;2DQFW2&amp;#43;3JTE&amp;#43;5YJRM&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;MixHost&lt;/a&gt;では不要な記載なのですが、移行後もこの記載を残したままにしていて、ここで指定しているPHPのバージョンを&lt;strong&gt;PHP5.6&lt;/strong&gt;に設定していました。&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;AddHandler application/x-httpd-php56cgi .php&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;以下のようにバージョン設定が異なっているのが原因でした。&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;a class=&#34;link&#34; href=&#34;https://px.a8.net/svt/ejp?a8mat=2ZF6W2&amp;#43;2DQFW2&amp;#43;3JTE&amp;#43;5YJRM&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;MixHost&lt;/a&gt;の管理画面**「cPanel」&lt;strong&gt;の&lt;/strong&gt;「MultiPHPマネージャー」&lt;strong&gt;で設定しているバージョンはデフォルトの&lt;/strong&gt;7.0**&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;.htaccess&lt;/strong&gt;ではバージョンでは&lt;strong&gt;5.6&lt;/strong&gt;を指定&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;p&gt;&lt;img class=&#34;gallery-image&#34; data-flex-basis=&#34;356px&#34; data-flex-grow=&#34;148&#34; height=&#34;404&#34; loading=&#34;lazy&#34; sizes=&#34;(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px&#34; src=&#34;https://qwerty.work/post/2018/04/mixhost-phpinfo-403-htaccess/images/No-01.jpg&#34; width=&#34;600&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;img class=&#34;gallery-image&#34; data-flex-basis=&#34;437px&#34; data-flex-grow=&#34;182&#34; height=&#34;329&#34; loading=&#34;lazy&#34; sizes=&#34;(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px&#34; src=&#34;https://qwerty.work/post/2018/04/mixhost-phpinfo-403-htaccess/images/No-02.jpg&#34; width=&#34;600&#34;&gt;&lt;/p&gt;&#xA;&lt;h3 id=&#34;削除またはコメントアウトで解決&#34;&gt;削除またはコメントアウトで解決&#xA;&lt;/h3&gt;&lt;p&gt;&lt;strong&gt;「MultiPHPマネージャー」&lt;strong&gt;でバージョンを&lt;/strong&gt;7.0→7.2&lt;/strong&gt;に変更して、上記の**.htaccess&lt;strong&gt;にある1行を削除、または行の先頭に&lt;/strong&gt;＃&lt;strong&gt;を入れてコメントアウトしたら正常に&lt;/strong&gt;phpinfo()**が表示されました。&lt;/p&gt;&#xA;&lt;p&gt;&lt;img class=&#34;gallery-image&#34; data-flex-basis=&#34;444px&#34; data-flex-grow=&#34;185&#34; height=&#34;324&#34; loading=&#34;lazy&#34; sizes=&#34;(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px&#34; src=&#34;https://qwerty.work/post/2018/04/mixhost-phpinfo-403-htaccess/images/No-03.jpg&#34; width=&#34;600&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;.htaccess&lt;/strong&gt;と&lt;strong&gt;MultiPHPマネージャー&lt;/strong&gt;の両方でPHPのバージョンを指定して、5.0系または7.0系でそれぞれバージョンが0.1とか0.2とかの違いだとエラーは出ませんでしたが、.htaccessでバージョン指定する理由も特にないと思いますので、削除かコメントアウトしておくほうが無難です。&lt;/p&gt;&#xA;&lt;p&gt;&lt;a class=&#34;link&#34; href=&#34;https://px.a8.net/svt/ejp?a8mat=2ZF6W2&amp;#43;2DQGNU&amp;#43;3JTE&amp;#43;5ZU29&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;&#xA;&lt;/a&gt;&lt;/p&gt;&#xA;</description>
        </item><item>
            <title>PHPのバージョンアップで発生するタイムゾーンエラーの対処方法</title>
            <link>https://qwerty.work/post/2015/09/php-error-defaulttimezone/</link>
            <pubDate>Wed, 09 Sep 2015 00:17:00 +0900</pubDate>
            <guid>https://qwerty.work/post/2015/09/php-error-defaulttimezone/</guid>
            <description>&lt;p&gt;使用しているレンタルサーバーのバージョンが上がったせいか、今まで正常に動いていたPHPのスクリプトでエラーが出始めた。&lt;/p&gt;&#xA;&lt;h3 id=&#34;エラーの内容&#34;&gt;エラーの内容&#xA;&lt;/h3&gt;&lt;p&gt;なにやらデフォルトの&lt;strong&gt;タイムゾーン&lt;/strong&gt;を設定しろ的な**date_default_timezone_set()**に関するエラー。&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;Warning&lt;/strong&gt;: date(): It is not safe to rely on the system&amp;rsquo;s timezone settings. You are &lt;em&gt;required&lt;/em&gt; to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone &amp;lsquo;UTC&amp;rsquo; for now, but please set date.timezone to select your timezone. in /public_html/qwerty.work/lib/***.php on line 123&lt;/p&gt;&#xA;&lt;h3 id=&#34;対処法方法&#34;&gt;対処法方法&#xA;&lt;/h3&gt;&lt;p&gt;タイムゾーンの設定はphp.iniか.htaccessでするか、スクリプト内に宣言するかなどできます。&lt;/p&gt;&#xA;&lt;h4 id=&#34;phpiniの場合&#34;&gt;php.iniの場合&#xA;&lt;/h4&gt;&lt;p&gt;[Date]セクション内を編集&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;;date.timezone =&#xA;  　　　↓↓↓&#xA;date.timezone = Asia/Tokyo&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;※スクリプト全てに対して適用されます&lt;/p&gt;&#xA;&lt;h4 id=&#34;htaccessの場合&#34;&gt;.htaccessの場合&#xA;&lt;/h4&gt;&lt;p&gt;以下を追加&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;php_value date.timezone Asia/Tokyo&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;※.htaccess制御範囲内のスクリプト全てに対して適用されます&lt;/p&gt;&#xA;&lt;h4 id=&#34;スクリプト内で宣言する場合&#34;&gt;スクリプト内で宣言する場合&#xA;&lt;/h4&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-php&#34; data-lang=&#34;php&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;date_default_timezone_set&lt;/span&gt;(&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#39;Asia/Tokyo&amp;#39;&lt;/span&gt;);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;※記述を追加したスクリプトのみに対して適用されます&lt;/p&gt;&#xA;</description>
        </item><item>
            <title>YSlowのUse cookie-free domain対策のメモ</title>
            <link>https://qwerty.work/post/2015/04/yslowuse_cookie-free_domain/</link>
            <pubDate>Sat, 11 Apr 2015 13:45:31 +0900</pubDate>
            <guid>https://qwerty.work/post/2015/04/yslowuse_cookie-free_domain/</guid>
            <description>&lt;p&gt;YSlowの&lt;strong&gt;Use cookie-free domain&lt;/strong&gt;対策用として.htaccessに静的コンテンツのCookieを削除する方法を見つけたのでメモ。&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&amp;lt;FilesMatch &amp;#34;\.(css|js|jpg|jpeg|png|gif)$&amp;#34;&amp;gt;&amp;lt;br&amp;gt;    RequestHeader unset Cookie&amp;lt;br&amp;gt;    Header unset Cookie&amp;lt;br&amp;gt;    Header unset Set-Cookie&amp;lt;br&amp;gt;&amp;lt;/FilesMatch&amp;gt;&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;結局、静的コンテンツ用にサブドメインを用意してみましたが、CDNの&lt;a class=&#34;link&#34; href=&#34;https://www.cloudflare.com/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;CloudFlare&lt;/a&gt;を使っていると、この設定をしてもサブドメイン経由で表示する画像などに&lt;a class=&#34;link&#34; href=&#34;https://www.cloudflare.com/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;CloudFlare&lt;/a&gt;のクッキーが加えられ、完全なクッキーレスにはできないようです。&lt;/p&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;参考：&lt;a class=&#34;link&#34; href=&#34;https://support.cloudflare.com/hc/en-us/articles/200170156-What-does-the-CloudFlare-cfduid-cookie-do-&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;What does the CloudFlare cfduid cookie do? - CloudFlare Support&lt;/a&gt;&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;</description>
        </item><item>
            <title>日本語を含むURLのRewriteは.htaccessをBOMなしで保存する</title>
            <link>https://qwerty.work/post/2013/11/urlbomutf-8n/</link>
            <pubDate>Fri, 08 Nov 2013 17:25:54 +0900</pubDate>
            <guid>https://qwerty.work/post/2013/11/urlbomutf-8n/</guid>
            <description>&lt;p&gt;mod_rewriteで日本語を含むURLからのアクセスをリダイレクトしようと.htaccessに以下を記述しました。結局は以下の書き方で正しかったのですが、404エラーや500エラーが出て動きませんでした。いろいろなサイトを参考に試行錯誤するものの時間ばかり消費して心が折れそうになりました。&lt;/p&gt;&#xA;&lt;h2 id=&#34;ブログにアクセスがあったらhttpqwertyworkblogにリダイレクトする&#34;&gt;&lt;a class=&#34;link&#34; href=&#34;http://qwerty.work/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;http://qwerty.work/&lt;/a&gt;ブログ/にアクセスがあったら、http://qwerty.work/blog/にリダイレクトする&#xA;&lt;/h2&gt;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;Redirect permanent /ブログ/ http://qwerty.work/blog/&amp;lt;br&amp;gt;&#xA;または&amp;lt;br&amp;gt;&#xA;RewriteRule ^ブログ/$ /blog/ [R,L]&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt; &lt;/p&gt;&#xA;&lt;p&gt;上記で正しく動くはずが動かなかったのは.htaccessをUTF-8の「BOMあり」で保存していたのが原因でした。BOMがどういうものかわかりませんが、「UTF-8（BOMあり）」で保存すると、例えURL内の文字や.htaccessの文字がちゃんとURLエンコードされていても転送元にエンコード文字や日本語があるとエラーになるようです。&lt;/p&gt;&#xA;&lt;p&gt;「&lt;a class=&#34;link&#34; href=&#34;http://blog.livedoor.jp/yuukin77/archives/51833302.html&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;UTF-8とUTF-8Nの違いによるワナ&lt;/a&gt;」を参考に「BOMなし」のUTF-8（UTF-8N）で保存したら、ちゃんとリダイレクトできました。メモ帳でできるかどうかわかりませんが、私の場合、テキストエディターの&lt;a class=&#34;link&#34; href=&#34;http://jp.emeditor.com/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;EmEditor&lt;/a&gt;で「BOMなし」保存しました。&lt;/p&gt;&#xA;&lt;p&gt; &lt;/p&gt;&#xA;&lt;p&gt;ちなみに転送元の「ブログ」はUTF-8でダイレクト（URLエンコードなし）で書かないと動かないようです。&lt;/p&gt;&#xA;&lt;p&gt;逆に、転送先に日本語が含まれている場合は、URLエンコードしていないとダメです。&lt;/p&gt;&#xA;&lt;h2 id=&#34;にアクセスがあったらhttpqwertyworkブログにリダイレクトする&#34;&gt;&lt;a class=&#34;link&#34; href=&#34;http://qwerty.work/blog/&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;&#xA;    &gt;http://qwerty.work/blog/&lt;/a&gt;にアクセスがあったら、http://qwerty.work/ブログ/にリダイレクトする&#xA;&lt;/h2&gt;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;RewriteRule ^blog/$ /¥%e3¥%83¥%96¥%e3¥%83¥%ad¥%e3¥%82¥%b0/ [NE,R,L]&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;また、URLエンコードされた文字列の「%」の前に「\」を付けてエスケーブさせておくのと、「NE」を行末に入れておかないとURLエンコードの文字列のまま出力されたり、「%」なしの文字列が表示されたりします。&lt;/p&gt;&#xA;</description>
        </item><item>
            <title>.htaccessでスマートホン用のサイトに転送</title>
            <link>https://qwerty.work/post/2012/09/htaccess/</link>
            <pubDate>Wed, 26 Sep 2012 22:02:59 +0900</pubDate>
            <guid>https://qwerty.work/post/2012/09/htaccess/</guid>
            <description>&lt;p&gt;Apatchのmod_rewriteを使ってスマートホン用のサイトにリダイレクトさせる方法をメモ。&lt;/p&gt;&#xA;&lt;p&gt;MovableTypeのプラグインを組み込んでスマホ用のブログページを作りました。&lt;/p&gt;&#xA;&lt;p&gt;PC用のブログはルートディレクトリの「blog」で、スマートホン用のブログを「blog」の中の「i」にしたとします。&lt;/p&gt;&#xA;&lt;p&gt;&lt;img alt=&#34;ディレクトリ&#34; class=&#34;gallery-image&#34; data-flex-basis=&#34;496px&#34; data-flex-grow=&#34;206&#34; height=&#34;150&#34; loading=&#34;lazy&#34; sizes=&#34;(max-width: 767px) calc(100vw - 30px), (max-width: 1023px) 700px, (max-width: 1279px) 950px, 1232px&#34; src=&#34;https://qwerty.work/post/2012/09/htaccess/images/WS000000.jpg&#34; width=&#34;310&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt; &lt;/p&gt;&#xA;&lt;p&gt;スマートホンからアクセスを転送するため、「blog」ディレクトリに以下の内容で.htaccessを作成します。&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;#スマホサイトにリダイレクト&#xA;RewriteEngine On&#xA;RewriteBase /blog&#xA;RewriteCond %{REQUEST_URI} !^/blog/i/.*$&#xA;RewriteCond %{REQUEST_URI} !^(.JPG|.jpg|.GIF|.gif|.PNG|.png) [NC]&#xA;RewriteCond %{HTTP_USER_AGENT} ^(iPhone|iPod|Android|BlackBerry|Windows.Phone) [NC]&#xA;RewriteCond %{HTTP_USER_AGENT} !iPad [NC]&#xA;RewriteRule ^(.*)$ /blog/i/$1 [R=301,L]&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt; &lt;/p&gt;&#xA;&lt;p&gt;もし、画像やiPadを除き「blog」にスマートホンからアクセスがあった場合は「i」にリダイレクトするという内容。&lt;/p&gt;&#xA;&lt;p&gt;「i」ディレクトリには画像がないため、ブログ内の画像のソースやリンクまでリダイレクトされると画像が表示されず困るので、画像はリダイレクトしないように5行目を加えています。&lt;/p&gt;&#xA;</description>
        </item><item>
            <title>携帯電話からのアクセスは自動的にモバイルサイトへ転送</title>
            <link>https://qwerty.work/post/2009/11/htaccess-rewriterule-mobile/</link>
            <pubDate>Sun, 22 Nov 2009 17:50:45 +0900</pubDate>
            <guid>https://qwerty.work/post/2009/11/htaccess-rewriterule-mobile/</guid>
            <description>&lt;p&gt;よくわからないまま、以下の内容をコピーして.htaccessに貼り付けたらうまくいった。&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;RewriteEngine On&amp;lt;br /&amp;gt;RewriteCond %{HTTP_USER_AGENT} ^(DoCoMo|KDDI|DDIPOKET|UP\.Browser|J-PHONE|Vodafone|SoftBank)&amp;lt;br /&amp;gt;RewriteRule ^$ http://www.example.com/mobile [R]&#xA;&lt;/code&gt;&lt;/pre&gt;</description>
        </item></channel>
</rss>
