質問編集履歴

1

.htaccess情報を追記

2019/02/05 01:29

投稿

yokoyamax
yokoyamax

スコア16

test CHANGED
File without changes
test CHANGED
@@ -32,6 +32,328 @@
32
32
 
33
33
 
34
34
 
35
+ ### 現環境
36
+
37
+ サイトはSIRIUSというCMSで構成されています。
38
+
39
+ PC/SPでワンソースではなく、SPはサイト/sp/のようなディレクトリ構成です。
40
+
41
+
42
+
43
+ 以下、.htaccessです。
44
+
45
+
46
+
47
+ **PC**
48
+
49
+ ```htaccess
50
+
51
+ Header set Content-Security-Policy: upgrade-insecure-requests
52
+
53
+
54
+
55
+ RewriteEngine on
56
+
57
+
58
+
59
+ RewriteCond %{THE_REQUEST} ^.*/index.html
60
+
61
+
62
+
63
+ RewriteRule ^(.*)index.html$ http://xn--wlr53q.net/$1 [R=301,L]
64
+
65
+ RewriteEngine on
66
+
67
+
68
+
69
+ RewriteCond %{HTTP_HOST} ^www.xn--wlr53q.net
70
+
71
+
72
+
73
+ RewriteRule ^(.*)$ http://xn--wlr53q.net/$1 [R=301,L]
74
+
75
+ RewriteCond %{HTTP_USER_AGENT} (iPhone|iPod|Android|BlackBerry)
76
+
77
+ RewriteRule ^(.*).js iphone/$1.js [L]
78
+
79
+ RewriteCond %{HTTPS} off
80
+
81
+ RewriteRule ^(.*)$ https://xn--wlr53q.net/$1 [R=301,L]
82
+
83
+ RewriteCond %{HTTP_HOST} ^www.xn--wlr53q.net$
84
+
85
+ RewriteRule ^(.*)$ https://xn--wlr53q.net/$1 [R=301,L]
86
+
87
+
88
+
89
+ <IfModule mod_deflate.c>
90
+
91
+ SetOutputFilter DEFLATE
92
+
93
+ BrowserMatch ^Mozilla/4.0[678] no-gzip
94
+
95
+ BrowserMatch ^Mozilla/4 gzip-only-text/html
96
+
97
+ BrowserMatch \bMSIE\s(7|8) !no-gzip !gzip-only-text/html
98
+
99
+
100
+
101
+ Header append Vary Accept-Encoding env=!dont-vary
102
+
103
+
104
+
105
+ # 画像は再圧縮しない
106
+
107
+ SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|ico)$ no-gzip dont-vary
108
+
109
+
110
+
111
+ # 圧縮設定
112
+
113
+ AddOutputFilterByType DEFLATE text/plain
114
+
115
+ AddOutputFilterByType DEFLATE text/html
116
+
117
+ AddOutputFilterByType DEFLATE text/xml
118
+
119
+ AddOutputFilterByType DEFLATE text/css
120
+
121
+ AddOutputFilterByType DEFLATE text/js
122
+
123
+ AddOutputFilterByType DEFLATE image/svg+xml
124
+
125
+ AddOutputFilterByType DEFLATE application/xml
126
+
127
+ AddOutputFilterByType DEFLATE application/xhtml+xml
128
+
129
+ AddOutputFilterByType DEFLATE application/rss+xml
130
+
131
+ AddOutputFilterByType DEFLATE application/atom_xml
132
+
133
+ AddOutputFilterByType DEFLATE application/javascript
134
+
135
+ AddOutputFilterByType DEFLATE application/x-javascript
136
+
137
+ AddOutputFilterByType DEFLATE application/x-httpd-php
138
+
139
+ </IfModule>
140
+
141
+
142
+
143
+ AddType image/svg+xml .svg .svgz
144
+
145
+ AddEncoding gzip .svgz
146
+
147
+ <ifModule mod_headers.c>
148
+
149
+ Header Set Vary User-Agent
150
+
151
+ </ifModule>
152
+
153
+
154
+
155
+ RewriteEngine Off
156
+
157
+ RewriteEngine On
158
+
159
+ <ifModule mod_expires.c>
160
+
161
+ ExpiresActive On
162
+
163
+ ExpiresByType text/css "access plus 7 days"
164
+
165
+ ExpiresByType image/bmp "access plus 10 days"
166
+
167
+ ExpiresByType image/gif "access plus 10 days"
168
+
169
+ ExpiresByType image/jpg "access plus 10 days"
170
+
171
+ ExpiresByType image/jpeg "access plus 10 days"
172
+
173
+ ExpiresByType image/png "access plus 10 days"
174
+
175
+ ExpiresByType text/js "access plus 10 days"
176
+
177
+ ExpiresByType text/javascript "access plus 10 days"
178
+
179
+ ExpiresByType text/x-javascript "access plus 10 days"
180
+
181
+ ExpiresByType application/javascript "access plus 10 days"
182
+
183
+ ExpiresByType application/x-javascript "access plus 10 days"
184
+
185
+ </ifModule>
186
+
187
+
188
+
189
+ RewriteBase /
190
+
191
+ RewriteCond %{HTTP_USER_AGENT} (iPhone|iPod|Android.*Mobile|Windows.*Phone|BlackBerry)
192
+
193
+ RewriteRule ^$ iphone/redirect.php?f=index.html [L]
194
+
195
+ RewriteCond %{HTTP_USER_AGENT} (iPhone|iPod|Android.*Mobile|Windows.*Phone|BlackBerry)
196
+
197
+ RewriteRule ^(.*).html iphone/redirect.php?f=$1.html [L]
198
+
199
+ RewriteCond %{HTTP_USER_AGENT} (iPhone|iPod|Android.*Mobile|Windows.*Phone|BlackBerry)
200
+
201
+ RewriteRule ^(.*).css iphone/$1.css [L]
202
+
203
+ RewriteCond %{HTTP_USER_AGENT} (iPhone|iPod|Android.*Mobile|Windows.*Phone|BlackBerry)
204
+
205
+ RewriteRule ^img/(.*) iphone/img/$1 [L]
206
+
207
+ RewriteCond %{HTTP_USER_AGENT} (iPhone|iPod|Android.*Mobile|Windows.*Phone|BlackBerry)
208
+
209
+ RewriteRule ^(.*)/ iphone/redirect.php?f=$1/index.html [L]
210
+
211
+ RewriteCond %{HTTP_USER_AGENT} (iPhone|iPod|Android.*Mobile|Windows.*Phone|BlackBerry)
212
+
213
+ RewriteRule ^(.*) iphone/$1 [L]
214
+
215
+
216
+
217
+ RewriteCond %{HTTP_USER_AGENT} ^(DoCoMo|KDDI|UP.Browser|J-PHONE|Vodafone|SoftBank)
218
+
219
+ RewriteRule ^$ m/redirect.php?f=index.html [L]
220
+
221
+ RewriteCond %{HTTP_USER_AGENT} ^(DoCoMo|KDDI|UP.Browser|J-PHONE|Vodafone|SoftBank)
222
+
223
+ RewriteRule ^(.*).html m/redirect.php?f=$1.html [L]
224
+
225
+ RewriteCond %{HTTP_USER_AGENT} ^(DoCoMo|KDDI|UP.Browser|J-PHONE|Vodafone|SoftBank)
226
+
227
+ RewriteRule ^img/(.*) m/img/$1 [L]
228
+
229
+ RewriteCond %{HTTP_USER_AGENT} ^(DoCoMo|KDDI|UP.Browser|J-PHONE|Vodafone|SoftBank)
230
+
231
+ RewriteRule ^(.*)/ m/redirect.php?f=$1/index.html [L]
232
+
233
+ RewriteCond %{HTTP:Accept-Encoding} gzip
234
+
235
+ RewriteCond %{REQUEST_FILENAME}.gz -s
236
+
237
+ RewriteRule .+ %{REQUEST_URI}.gz
238
+
239
+
240
+
241
+ <FilesMatch ".css.gz$">
242
+
243
+ ForceType text/css;charset=Shift_JIS
244
+
245
+ AddEncoding x-gzip .gz
246
+
247
+ </FilesMatch>
248
+
249
+ <FilesMatch ".js.gz$">
250
+
251
+ ForceType text/javascript;charset=UTF-8
252
+
253
+ AddEncoding x-gzip .gz
254
+
255
+ </FilesMatch>
256
+
257
+ ```
258
+
259
+
260
+
261
+
262
+
263
+ **SP**
264
+
265
+ ```htaccess
266
+
267
+ <ifModule mod_expires.c>
268
+
269
+ ExpiresActive On
270
+
271
+ ExpiresByType text/css "access plus 7 days"
272
+
273
+ ExpiresByType image/bmp "access plus 10 days"
274
+
275
+ ExpiresByType image/gif "access plus 10 days"
276
+
277
+ ExpiresByType image/jpg "access plus 10 days"
278
+
279
+ ExpiresByType image/jpeg "access plus 10 days"
280
+
281
+ ExpiresByType image/png "access plus 10 days"
282
+
283
+ ExpiresByType text/js "access plus 10 days"
284
+
285
+ ExpiresByType text/javascript "access plus 10 days"
286
+
287
+ ExpiresByType text/x-javascript "access plus 10 days"
288
+
289
+ ExpiresByType application/javascript "access plus 10 days"
290
+
291
+ ExpiresByType application/x-javascript "access plus 10 days"
292
+
293
+ </ifModule>
294
+
295
+ RewriteEngine Off
296
+
297
+ RewriteEngine On
298
+
299
+ RewriteCond %{HTTP_USER_AGENT} (DoCoMo|KDDI|DDIPOKET|UP.Browser|J-PHONE|Vodafone|SoftBank)
300
+
301
+ RewriteRule ^(.*)$ https://xn--wlr53q.net/$1 [R,L]
302
+
303
+ RewriteCond %{HTTP_USER_AGENT} !(iPhone|iPod|Android.*Mobile|Windows.*Phone|BlackBerry)
304
+
305
+ RewriteRule ^(.*)$ https://xn--wlr53q.net/$1 [R,L]
306
+
307
+ RewriteCond %{REQUEST_FILENAME} !-f
308
+
309
+ RewriteCond %{REQUEST_FILENAME} !redirect.php
310
+
311
+ RewriteRule ^(.*?)$ redirect.php?nf=$1 [L]
312
+
313
+ RewriteCond %{HTTP:Accept-Encoding} gzip
314
+
315
+ RewriteCond %{REQUEST_FILENAME}.gz -s
316
+
317
+ RewriteRule .+ %{REQUEST_URI}.gz
318
+
319
+
320
+
321
+ <FilesMatch ".css.gz$">
322
+
323
+ ForceType text/css;charset=Shift_JIS
324
+
325
+ AddEncoding x-gzip .gz
326
+
327
+ </FilesMatch>
328
+
329
+ <FilesMatch ".js.gz$">
330
+
331
+ ForceType text/javascript;charset=UTF-8
332
+
333
+ AddEncoding x-gzip .gz
334
+
335
+ </FilesMatch>
336
+
337
+ ```
338
+
339
+
340
+
341
+ その他、SVGを導入した際に画像と認識されない問題が発生した為、CMS発行元に問い合わせたところ、
342
+
343
+ SVGディレクトリに.htaccessを追加すればいいという助言を受け、以下をサイト/svg/とサイト/sp/svg/に置いています。
344
+
345
+
346
+
347
+ ```htaccsess
348
+
349
+ RewriteEngine Off
350
+
351
+ ```
352
+
353
+
354
+
355
+
356
+
35
357
 
36
358
 
37
359
  ### 実現したいこと