<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="https://tm.root-n.com/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel>
        <title>Tipsというかメモ server:apache:htaccess</title>
        <description></description>
        <link>https://tm.root-n.com/</link>
        <lastBuildDate>Tue, 18 Nov 2025 19:21:05 +0900</lastBuildDate>
        <generator>FeedCreator 1.7.2-ppt DokuWiki</generator>
        <image>
            <url>https://tm.root-n.com/lib/images/favicon.ico</url>
            <title>Tipsというかメモ</title>
            <link>https://tm.root-n.com/</link>
        </image>
        <item>
            <title>apache :: レスポンスをgzip圧縮する</title>
            <link>https://tm.root-n.com/server:apache:htaccess:deflate_response</link>
            <description>.htaccess


AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript</description>
        <category>server:apache:htaccess</category>
            <pubDate>Thu, 10 Apr 2014 20:49:48 +0900</pubDate>
        </item>
        <item>
            <title>apache :: ファイル名でアクセス制限</title>
            <link>https://tm.root-n.com/server:apache:htaccess:files_directive</link>
            <description>apache :: ファイル名でアクセス制限


Files ディレクティブ でアクセス制限を行う。

.htaccess

*.inc.php / *.conf.php で終わるファイルにアクセスを禁止する。
&lt;Files ~ &quot;^.*\.(inc|conf)\.php$&quot;&gt;
    order deny,allow
    deny from all
&lt;/Files&gt;


secret_log というファイルにアクセスを禁止する。</description>
        <category>server:apache:htaccess</category>
            <pubDate>Sun, 16 Mar 2008 22:48:24 +0900</pubDate>
        </item>
        <item>
            <title>apache :: wwwなしURLを、wwwありURLにリダイレクトさせる(URL正規化)</title>
            <link>https://tm.root-n.com/server:apache:htaccess:normalize_url</link>
            <description>wwwなしURLを、wwwありURLにリダイレクトさせる

.htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]


上の逆

.htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]




www 以外は、すべて www にリダイレクト

.htaccess
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.example\.com
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301,L]


test と www 以外は、すべて www にリダイレクト

.htaccess
RewriteEngine on
RewriteCond %{H…</description>
        <category>server:apache:htaccess</category>
            <pubDate>Mon, 07 Jan 2013 16:31:02 +0900</pubDate>
        </item>
        <item>
            <title>apache :: ドットから始まるファイル、ディレクトリにアクセス禁止</title>
            <link>https://tm.root-n.com/server:apache:htaccess:redirectmatch</link>
            <description>.htaccess .secret.txt .svn 等のドットから始まるファイル、ディレクトリにアクセス禁止
#403 Forbidden
RedirectMatch 403 /\.


ちなみにディレクトリのみに限定したければ
#403 Forbidden
RedirectMatch 403 /\..*/


どこぞのサイトには以下のように Directoryディレクティブ でいけると書いてあったが、

私の環境では 500 Internal Server Error が発生して動作しなかった。。</description>
        <category>server:apache:htaccess</category>
            <pubDate>Sun, 16 Mar 2008 22:48:24 +0900</pubDate>
        </item>
        <item>
            <title>apache :: Expiresヘッダーを送出する</title>
            <link>https://tm.root-n.com/server:apache:htaccess:send_expires_header</link>
            <description>.htaccess


ExpiresActive On
ExpiresByType text/css &quot;access plus 3 days&quot;
ExpiresByType application/x-javascript &quot;access plus 3 days&quot;
ExpiresByType image/jpeg &quot;access plus 3 days&quot;
ExpiresByType image/png &quot;access plus 3 days&quot;
ExpiresByType image/gif &quot;access plus 3 days&quot;
ExpiresByType image/x-icon &quot;access plus 3 days&quot;</description>
        <category>server:apache:htaccess</category>
            <pubDate>Thu, 10 Apr 2014 10:16:37 +0900</pubDate>
        </item>
        <item>
            <title>apache :: 日本語表示できるブラウザからのアクセスのみ許可する</title>
            <link>https://tm.root-n.com/server:apache:htaccess:setenvif_accept-language</link>
            <description>.htaccess
SetEnvIf Accept-Language ja allow_lang
Order deny,allow
deny from all
allow from env=allow_lang

日本語表示できないブラウザからのアクセスは「sorry.html」に飛ばす。SetEnvIf Accept-Language ja allow_lang
Order deny,allow
deny from all
allow from env=allow_lang
ErrorDocument 403 /sorry.html</description>
        <category>server:apache:htaccess</category>
            <pubDate>Sun, 16 Mar 2008 22:48:24 +0900</pubDate>
        </item>
        <item>
            <title>apache :: 第三者サイトからの画像の直リンク、サムネイルの埋め込みを ...</title>
            <link>https://tm.root-n.com/server:apache:htaccess:setenvif_referer</link>
            <description>apache :: 第三者サイトからの画像の直リンク、サムネイルの埋め込みを禁止する


画像の直リンクを防止するには .htaccess で Referer によるアクセス制限を施すと簡単に実現できる。

&lt;img&gt;タグでサムネイル等の画像を第三者のサイトに埋め込まれることも防止できる。

以下の例は Referer が http://example.{com,org}/ から始まるリクエストには画像を返すが、それ以外からのリクエストには dummy.gif を返す。…</description>
        <category>server:apache:htaccess</category>
            <pubDate>Sun, 16 Mar 2008 22:48:25 +0900</pubDate>
        </item>
        <item>
            <title>apache :: User-Agent でアクセス制限</title>
            <link>https://tm.root-n.com/server:apache:htaccess:setenvif_user-agent</link>
            <description>.htaccess

User-Agentに `NG-CRAWLER' が含まれている場合はアクセスを禁止する。
SetEnvIf User-Agent &quot;NG-CRAWLER&quot; deny_robot
Order deny,allow
deny from env=deny_robot


User-Agentに `NG-CRAWLER' が含まれている場合はアクセスを禁止するが、`OK-CRAWLER' が含まれている場合は許可する。</description>
        <category>server:apache:htaccess</category>
            <pubDate>Sun, 16 Mar 2008 22:48:25 +0900</pubDate>
        </item>
    </channel>
</rss>
