This repository has been archived by the owner on Nov 2, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.htaccess
268 lines (232 loc) · 22 KB
/
.htaccess
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
################################################################################
# 基本設定
################################################################################
AddDefaultCharset UTF-8
AddType application/x-httpd-php .php .html
AddType application/xml .rdf .xml
AddType image/x-icon .ico
AddType text/javascript .js
AddType text/vtt .vtt
DirectoryIndex index.php index.html index.xml 01.html
Options +FollowSymLinks +MultiViews -Indexes
RewriteEngine On
################################################################################
# セキュリティ
################################################################################
Header always append Strict-Transport-Security max-age=31536000
Header always append X-Content-Type-Options nosniff
Header always append X-XSS-Protection "1; mode=block"
Header always append X-Frame-Options "ALLOW-FROM https://secure.mozilla.jp"
Header always append Content-Security-Policy " \
default-src 'self'; \
connect-src 'self' https://*.typekit.net; \
script-src 'self' https://use.typekit.net https://www.google-analytics.com https://maps.googleapis.com https://amara.org; \
style-src 'self' 'unsafe-inline' https://use.typekit.net; \
font-src 'self' data: https://use.typekit.net; \
child-src https://www.youtube-nocookie.com https://www.youtube.com https://amara.org; \
img-src *; \
media-src *; "
################################################################################
# パフォーマンス向上
################################################################################
# gzip 圧縮を使用
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# キャッシュの有効期限を明示
ExpiresActive On
## 画像、CSS、JavaScript など、デフォルトは 1 年 = 事実上無期限
ExpiresDefault "access plus 1 year"
## ページは 24 時間
ExpiresByType text/html "access plus 1 day"
## RSS フィードは 30 分
ExpiresByType application/xml "access plus 30 minutes"
# Etag を使わない
FileETag None
################################################################################
# リダイレクト - 正規化
# 以下、リダイレクトに関する注意事項については Intranet の記事を参照
# https://secure.mozilla.jp/intranet/WebDev/mozilla.jp/Redirects
################################################################################
# ホスト名の統一
RewriteCond %{HTTP_HOST} ^mozilla\.jp$
RewriteRule (.*) https://www.mozilla.jp/$1 [R=permanent,L]
# URL 正規化 (大文字を小文字に)
RewriteRule ^Firefox(.*) /firefox$1 [R=permanent]
RewriteRule ^Thunderbird(.*) /thunderbird$1 [R=permanent]
################################################################################
# mozilla.org へのリダイレクト
################################################################################
# Firefox
RewriteRule ^products/firefox(/?|/.+)$ https://www.mozilla.org/ja/firefox$1 [R=permanent,L]
RewriteRule ^products/download https://www.mozilla.org/ja/firefox/ [R=permanent,L]
RewriteRule ^firefox(?:/?|/index\.html)$ https://www.mozilla.org/ja/firefox/ [R=permanent,L]
RewriteRule ^firefox/landing(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/ [R=permanent,L]
RewriteRule ^firefox/(?:download|update|upgrade|new|fx|ie|fb|banners)/?$ https://www.mozilla.org/ja/firefox/ [R=permanent,L]
RewriteRule ^firefox/(?:happy|speed|bookmarks|try|independent)/?$ https://www.mozilla.org/ja/firefox/ [R=permanent,L]
RewriteRule ^firefox/download/(?:update|unsupported)(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/ [R=permanent,L]
RewriteRule ^firefox/(?:uninstall(-thanks)?|install-feedback)(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/ [R=permanent,L]
RewriteRule ^firefox/faq(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/ [R=permanent,L]
RewriteRule ^firefox/(?:channels?|preview|early_releases|rc|RC)(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/channel/ [R=permanent,L]
RewriteRule ^mobile/aurora(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/channel/ [R=permanent,L]
RewriteRule ^firefox/(?:android/)?beta/?$ https://www.mozilla.org/ja/firefox/channel/ [R=permanent,L]
RewriteRule ^firefox/(?:all(?:\.html|/?)?|download/all/?|locales/?)$ https://www.mozilla.org/ja/firefox/all/ [R=permanent,L]
RewriteRule ^firefox/(beta|aurora|developer|organizations)/all(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/$1/all/ [R=permanent,L]
RewriteRule ^firefox/(?:all-(?:beta|rc)(?:\.html)?|(?:download/)?beta/?)$ https://www.mozilla.org/ja/firefox/beta/all/ [R=permanent,L]
RewriteRule ^business/downloads/all(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/enterprise/#download [R=permanent,L]
RewriteRule ^firefox/(?:download/)?(?:aurora|developer)(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/developer/ [R=permanent,L]
RewriteRule ^(?:firefox/)?webdev(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/developer/ [R=permanent,L]
RewriteRule ^firefox/(?:family|products?)(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/products/ [R=permanent,L]
RewriteRule ^(?:products/?|projects(?:/?|/.+))$ https://www.mozilla.org/ja/firefox/products/ [R=permanent,L]
RewriteRule ^firefox/features/?$ https://www.mozilla.org/ja/firefox/desktop/ [R=permanent,L]
RewriteRule ^firefox/desktop(/(?:fast|trust|customize))?(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/desktop$1 [R=permanent,L]
RewriteRule ^firefox/(?:performance|underthehood)(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/desktop/fast/ [R=permanent,L]
RewriteRule ^firefox/security/?$ https://www.mozilla.org/ja/firefox/desktop/trust/ [R=permanent,L]
RewriteRule ^firefox/(?:customize|addons)/?$ https://www.mozilla.org/ja/firefox/desktop/customize/ [R=permanent,L]
RewriteRule ^firefox/(sync|hello|pocket|installer-help)(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/$1/ [R=permanent,L]
RewriteRule ^(?:firefox/)?dnt(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/dnt/ [R=permanent,L]
RewriteRule ^(?:firefox/)?mobile/sync(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/sync/ [R=permanent,L]
RewriteRule ^firefox/(?:features/)?geolocation(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/geolocation/ [R=permanent,L]
RewriteRule ^(?:m|firefox)/ios/?$ https://www.mozilla.org/ja/firefox/ios/ [R=permanent,L]
RewriteRule ^m(/.*)?$ https://www.mozilla.org/ja/firefox/android/ [R=permanent,L]
RewriteRule ^(?:firefox/)?(?:mobile|android)/?$ https://www.mozilla.org/ja/firefox/android/ [R=permanent,L]
RewriteRule ^firefox/android/(?:beta/)?faq/?$ https://www.mozilla.org/ja/firefox/android/ [R=permanent,L]
RewriteRule ^firefox/(\d+)\.0a2/(.*) https://www.mozilla.org/ja/firefox/$1.0a2/$2 [R=permanent,L]
RewriteRule ^firefox/android/(\d+)\.0a2/(.*) https://www.mozilla.org/ja/firefox/android/$1.0a2/$2 [R=permanent,L]
RewriteRule ^firefox/android/aurora(.*) https://www.mozilla.org/ja/firefox/android/aurora$1 [R=permanent,L]
RewriteRule ^firefox/([^/+])/auroranotes(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/$1/auroranotes/ [R=permanent,L]
RewriteRule ^firefox/([\w\.]+)/(firstrun|whatsnew|details)(?:/?|/.+)$ https://www.mozilla.org/ja/firefox/$1/$2/ [R=permanent,L]
RewriteRule ^(?:firefox/)?personas/?$ https://support.mozilla.org/ja/kb/use-themes-change-look-of-firefox [R=permanent,L]
RewriteRule ^firefox/tiles(?:/?|/.+)$ https://support.mozilla.org/ja/kb/about-tiles-new-tab [R=permanent,L]
RewriteRule ^\(ja\)/firefox/uninstall(?:/?|/.+)$ https://support.mozilla.org/ja/kb/uninstall-firefox-from-your-computer [R=permanent,L]
RewriteRule ^firefox/(?:security/)?phishing-protection(?:/?|/.+)$ https://support.mozilla.org/ja/kb/how-does-phishing-and-malware-protection-work [R=permanent,L]
RewriteRule ^firefox/(?:all-older(?:\.html)?|(?:download|locales)/older/?)$ https://support.mozilla.org/ja/kb/install-older-version-of-firefox [R=permanent,L]
RewriteRule ^firefox/search(?:/?|/.+)$ https://support.mozilla.org/ja/kb/use-search-bar-firefox [R=permanent,L]
RewriteRule ^firefox/livebookmarks(?:/?|/.+)$ https://support.mozilla.org/ja/kb/live-bookmarks [R=permanent,L]
RewriteRule ^firefox/security/identity(?:/?|/.+)$ https://support.mozilla.org/ja/kb/how-do-i-tell-if-my-connection-is-secure [R=permanent,L]
RewriteRule ^firefox/(?:central|tips|tour|releases/whatsnew)(?:/?|/.+)$ https://support.mozilla.org/ja/kb/get-started-firefox-overview-main-features [R=permanent,L]
RewriteRule ^firefox/android/devices(?:/?|/.+)$ https://support.mozilla.org/ja/kb/will-firefox-work-my-mobile-device [R=permanent,L]
RewriteRule ^(?:firefox/)?mobile/platforms(?:/?|/.+)$ https://support.mozilla.org/ja/kb/will-firefox-work-my-mobile-device [R=permanent,L]
RewriteRule ^firefox/addons/install(?:/?|/.+)$ https://support.mozilla.org/ja/kb/find-and-install-add-ons-add-features-to-firefox [R=permanent,L]
RewriteRule ^firefox/technology(?:/?|/.+)$ https://developer.mozilla.org/ja/docs/Web [R=permanent,L]
RewriteRule ^(?:firefox/marketplace|apps)(?:/?|/.+)$ https://marketplace.firefox.com/ [R=permanent,L]
RewriteRule ^firefox/(its-an-attack|its-a-trap)(?:\.html)$ https://www.itisatrap.org/firefox/$1.html [R=permanent,L]
# Firefox OS
RewriteRule ^(?:firefox/os/devices/)?flame(?:/?|/.+)$ https://developer.mozilla.org/ja/docs/Mozilla/B2G_OS/Phone_guide/Flame [R=permanent,L]
RewriteRule ^(?:mwc|firefoxos|firefox/(?:b2g|os))(?:/?|/.+)$ https://developer.mozilla.org/ja/docs/Mozilla/B2G_OS [R=permanent,L]
# Thunderbird
RewriteRule ^products/thunderbird(/?|/.*) https://www.thunderbird.net/ja/ [R=permanent,L]
RewriteRule ^thunderbird(/download)?/?$ https://www.thunderbird.net/ja/ [R=permanent,L]
RewriteRule ^thunderbird/features/?$ https://www.thunderbird.net/ja/features/ [R=permanent,L]
RewriteRule ^thunderbird/(?:channels?|preview|early_releases|rc|RC)/?$ https://www.thunderbird.net/ja/channel/ [R=permanent,L]
RewriteRule ^thunderbird/(?:all(?:\.html|/?)?|download/all/?|locales/?)$ https://www.thunderbird.net/ja/all/ [R=permanent,L]
RewriteRule ^thunderbird/(?:all-(?:beta|rc)(?:\.html)?|(?:download/)?beta/?)$ https://www.thunderbird.net/ja/beta/all/ [R=permanent,L]
RewriteRule ^thunderbird/(?:download/)?earlybird/?$ https://www.thunderbird.net/ja/earlybird/all/ [R=permanent,L]
RewriteRule ^thunderbird/(?:all-older(?:\.html)?|(?:download|locales)/older/?)$ https://www.thunderbird.net/ja/all/ [R=permanent,L]
RewriteRule ^thunderbird/([\w\.]+)/(start|whatsnew|details)(?:/?|/.+)$ https://www.thunderbird.net/ja/$1/$2/ [R=permanent,L]
# サポート
RewriteRule ^(?:(?:firefox|thunderbird)/)?support/community https://support.mozilla.org/ja/kb/get-community-support [R=permanent,L]
RewriteRule ^support/(firefox|thunderbird)(?:/?|/.+)$ https://support.mozilla.org/ja/products/$1 [R=permanent,L]
RewriteRule ^(firefox|thunderbird)/(?:support|help)(?:/?|/.+)$ https://support.mozilla.org/ja/products/$1 [R=permanent,L]
RewriteRule ^support(/?|/.+)$ https://support.mozilla.org/ja/ [R=permanent,L]
# リーガル
RewriteRule ^(?:about/)?legal/?$ https://www.mozilla.org/ja/about/legal/ [R=permanent,L]
RewriteRule ^privacy(?:-policy)?(?:/?|/.+)$ https://www.mozilla.org/ja/privacy/ [R=permanent,L]
RewriteRule ^legal/privacy/?$ https://www.mozilla.org/ja/privacy/ [R=permanent,L]
RewriteRule ^legal/privacy/japan/?$ - [G,L]
RewriteRule ^legal/privacy/(firefox|thunderbird)(?:/?|/.+)$ https://www.mozilla.org/ja/privacy/$1/ [R=permanent,L]
RewriteRule ^(firefox|thunderbird)/legal/privacy(?:/?|/.+)$ https://www.mozilla.org/ja/privacy/$1/ [R=permanent,L]
# セキュリティ
RewriteCond %{REQUEST_URI} !^/security/known-vulnerabilities(/?|/.*)$
RewriteRule ^security(/?|/.*)$ https://www.mozilla.org/ja/security$1 [R=permanent,L]
# その他
RewriteRule ^(?:firefox/security/)?plugincheck(?:/?|/.+)$ https://www.mozilla.org/ja/plugincheck/ [R=permanent,L]
RewriteRule ^(?:lightbeam|collusion)(?:/?|/.+)$ https://www.mozilla.org/ja/lightbeam/ [R=permanent,L]
RewriteRule ^firefox/brand(?:/?|/.+)$ https://www.mozilla.org/ja/styleguide/ [R=permanent,L]
RewriteRule ^mission(?:/?|/.+)$ https://www.mozilla.org/ja/mission/ [R=permanent,L]
RewriteRule ^about/contact(?:/?|\.html)$ https://www.mozilla.org/ja/contact/ [R=permanent,L]
RewriteRule ^about/licensing(?:/?|\.html)$ https://www.mozilla.org/ja/foundation/licensing/ [R=permanent,L]
RewriteRule ^about/(?:timeline|history)(?:/?|/.+)$ https://www.mozilla.org/ja/about/history/ [R=permanent,L]
RewriteRule ^about/(governance|partnerships)(?:/?|/.+)$ https://www.mozilla.org/ja/about/$1/ [R=permanent,L]
RewriteRule ^(?:about|foundation)/annualreport(/20\d\d)?(/\w+)?/?$ https://www.mozilla.org/ja/foundation/annualreport$1$2/ [R=permanent,L]
RewriteRule ^newsletter(?:/?|/.+)$ https://www.mozilla.org/ja/newsletter/ [R=permanent,L]
RewriteRule ^press(?:/?|/.+)$ https://blog.mozilla.org/press/ [R=permanent,L]
RewriteRule ^about/logo/?$ https://blog.mozilla.org/press/media-library/ [R=permanent,L]
RewriteRule ^persona/developer-faq(?:/?|/.+)$ https://developer.mozilla.org/ja/docs/Mozilla/Persona/FAQ [R=permanent,L]
RewriteRule ^persona(?:/?|/.+)$ https://developer.mozilla.org/ja/docs/Mozilla/Persona [R=permanent,L]
RewriteRule ^community/directory\.html\??.* https://wiki.mozilla.org/Websites/Directory [R=permanent,L]
RewriteRule ^careers?(?:/?|/.+)$ https://careers.mozilla.org/ [R=permanent,L]
RewriteRule ^about/careers(?:\.html|/?)$ https://careers.mozilla.org/ [R=permanent,L]
################################################################################
# 内部リダイレクト
################################################################################
# ビジネス
RewriteRule ^business/(?:downloads|profiles|resources|support)(?:/?|/.+)$ /business/ [R=permanent,L]
RewriteRule ^(?:(?:firefox|thunderbird)/)?organizations?(?:/?|/.+)$ /business/ [R=permanent,L]
# 製品
RewriteRule ^(?:firefox/)?(?:mobile/)?(?:home|iphone) /blog/entry/9902/ [R=permanent,L]
# イベント・キャンペーン
RewriteRule ^firefoxlive(?:/?|/.+)$ /blog/entry/7488/ [R=permanent,L]
RewriteRule ^firefoxflicks(?:/?|/.+)$ /blog/entry/10326/ [R=permanent,L]
# ブログ
RewriteRule ^blog/category/(firefox|thunderbird)-\d+/$ /blog/category/$1/ [R=permanent,L]
RewriteRule ^blog/archive/(20\d\d)/\d\d/$ /blog/archive/$1/ [R=permanent,L]
# その他
RewriteRule ^users/?$ / [R=permanent,L]
RewriteRule ^firefox/(?:about|organic|public)/?$ /about/ [R=permanent,L]
RewriteRule ^about/(?:whatis)?mozilla(?:\.html|/)?$ /about/ [R=permanent,L]
RewriteRule ^about/japan(?:\.html|/)?$ /about/ [R=permanent,L]
RewriteRule ^about/(?:get-involved|participate)(?:/?|/.+)$ /community/ [R=permanent,L]
RewriteRule ^(?:manyfaces|contribute|firefox/community)(?:/?|/.+)$ /community/ [R=permanent,L]
################################################################################
# 外部リダイレクト
################################################################################
# セキュリティ
RewriteRule ^security/known-vulnerabilities/(firefox|firefox-os|thunderbird|seamonkey|older-vulnerabilities)/?$ http://www.mozilla-japan.org/security/known-vulnerabilities/$1.html [R=permanent,L]
RewriteRule ^security/known-vulnerabilities/(firefox|thunderbird)-esr/? http://www.mozilla-japan.org/security/known-vulnerabilities/$1ESR.html [R=permanent,L]
RewriteRule ^security/known-vulnerabilities/(firefox|thunderbird|seamonkey)-(1|2|3).(0|1|2|5|6|7)/? http://www.mozilla-japan.org/security/known-vulnerabilities/$1$2$3.html [R=permanent,L]
RewriteRule ^security/known-vulnerabilities/(?:mozilla-)?suite/? http://www.mozilla-japan.org/security/known-vulnerabilities/suite17.html [R=permanent,L]
RewriteRule ^security/known-vulnerabilities/? http://www.mozilla-japan.org/security/known-vulnerabilities/ [R=permanent,L]
# その他
RewriteRule ^(?:firefox/)?videos?(?:/?|/.+)$ https://www.youtube.com/user/MozillaJP [R=permanent,L]
RewriteRule ^firefox/connect(?:/?|/.+)$ https://twitter.com/mozillajp [R=permanent,L]
RewriteRule ^(?:(?:firefox/)?students(?:/?|/.+)|st/?)$ http://fxstudent.tumblr.com/ [R=permanent,L]
RewriteRule ^events/?$ https://mozilla.doorkeeper.jp/ [R=permanent,L]
RewriteRule ^blog/feed/?$ https://medium.com/feed/mozilla-japan [R=permanent,L]
# 製品リリースノートなど (キャッチオール)
RewriteRule ^firefox/(.*)/$ https://www.mozilla.org/ja/firefox/$1/ [R=permanent,L]
RewriteRule ^thunderbird/(.*)/$ https://www.thunderbird.net/ja/thunderbird/$1/ [R=permanent,L]
################################################################################
# 内部リライトルール (リダイレクトせず、URL と異なる物理パスを表示させる)
# 各ルールのフラグに [R] が付いていないことに注意
################################################################################
# /static/ 以下のファイルを更新した場合は、HTML/CSS に書かれているファイル名の
# 末尾に YYYYMMDD 形式の日付もしくはバージョンを付けること。上記 ExpiresDefault の
# 指定通り、これらのファイルはブラウザー側で 1 年間キャッシュされるため、通常は
# ファイル名を変更しない限りブラウザーに表示されるファイルは更新されないことに注意。
# ただし、以下の RewriteRule のおかげで、実際のファイルをリネームする必要はない。
# (例: /static/styles/covehead/home-20110816 = /static/styles/covehead/home.css)
# (例: /static/scripts/lib/jquery/jquery-1.6.2.js = /static/scripts/lib/jquery/jquery.js)
RewriteRule ^static/([a-z]+)/(.*)-(\d{8,10})(\.([a-z0-9]{2,4}))?$ /static/$1/$2$4 [L]
RewriteRule ^static/scripts/lib/(.*)-([\d\.]+)\.js$ /static/scripts/lib/$1.js [L]
RewriteRule ^(.+)/static/(styles|scripts)/(.+)\-[0-9]+$ $1/static/$2/$3 [L]
# favicon
RewriteRule ^(firefox|thunderbird)/(?:.*/)?favicon\.ico$ /static/images/$1/favicon-32.ico?v=201711 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule favicon\.ico$ /static/images/global/favicon.ico [L]
################################################################################
# 先読みスクリプト
################################################################################
# すべての HTML ファイルを処理
Action init /includes/prefetch.php
AddHandler init .html
# CSS/JavaScript ファイルを最小化
Action minify /includes/minify.php
AddHandler minify .css .js
################################################################################
# エラーページ
################################################################################
ErrorDocument 403 /includes/prefetch.php?error=403
ErrorDocument 404 /includes/prefetch.php?error=404
ErrorDocument 410 /includes/prefetch.php?error=410