メインコンテンツへスキップ
kitlocal.dev

.htaccess生成

ローカルで実行

100% ブラウザ内で処理されます。入力や出力が端末の外に送信されることはありません。

リダイレクト、リライト、セキュリティ向けのApache .htaccessルールを生成します。

Apache ルール

リダイレクト、キャッシュ、SPA ルーティングをまとめたダウンロード可能な .htaccess ファイルを作成します。

クイック設定

Apache 2.4、該当モジュール、および AllowOverride 権限が必要です。ステージング環境でテストしてください。TLS終端プロキシ配下では、サーバー側で信頼できる HTTPS 検出を先に設定してください。

正規化リダイレクトは上記の固定ドメインを対象とします。「HTTPS を強制」が無効の場合、現在の HTTP または HTTPS スキームが維持されます。恒久リダイレクト (301) はブラウザにキャッシュされる場合があります。

.htaccess

# Generated by KitLocal — Apache 2.4; AllowOverride must permit these directives.

RewriteEngine On

# Canonical redirect (fixed host avoids trusting HTTP_HOST).
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} !^example\.com$ [NC]
RewriteRule ^ https://example.com%{REQUEST_URI} [R=301,L,NE]

<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/css application/json application/javascript image/svg+xml
</IfModule>

<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType text/css "access plus 1 week"
    ExpiresByType application/javascript "access plus 1 week"
</IfModule>

<IfModule mod_headers.c>
    Header always set X-Content-Type-Options "nosniff"
    Header always set Referrer-Policy "strict-origin-when-cross-origin"
</IfModule>
26 行893 バイト.htaccess