もう一人のY君

iPhoneアプリのレビューやアップデートレビューなどを書いています. たまに数学の記事も書きます.

もう一人のY君 MENU  MENU

(困った)Webサイトのgz圧縮がうまくいかない

 151204_00

  タイトルそのまんま, 困った…

 

gz圧縮とは

  まぁ自分もそこまで知ってるわけじゃありませんが, 通常ユーザーはウェブページのhtmlなどを読み込んで閲覧するんですが, gz圧縮をサポートしている場合, htmlなどを圧縮したgzファイルを読み込み, その場で展開することでそのページを開くことができます.

 

 gzファイルだと元ファイルよりいくらかサイズが小さいので, その分読み込みも, また通信量にもやさしいという双方にメリットのある手段です.

 

 元々小さいファイルには余り意味は無いですが, 僕が運営しているURLスキームのサイトのように1ページで膨大なコンテンツを抱えるページでは特に効果を発揮するとか何とか.

 

  実際これを採用してからGoogleなどでのパフォーマンス評価も上がっています.

 読み込み時間も格段に良くなっていました.

 

 

独自ドメイン後からおかしい

  サイトのトップページやURLスキームのトップページは問題なかったのでてっきり問題ないと思い込んでいました, 実際は酷いことに…

 

http://www.thetheorier.com/

↑スマホからこの記事のリンクを踏んでもダメでした…何で… 

 

http://www.thetheorier.com/urlscheme/top

 

  例えば上の2つは問題ないです.

 

http://www.thetheorier.com/urlscheme/A

 

  こっちは何故かアクセスできない

 

 151204_01

  アクセスすることなく, 何故か「A.gz」ファイルをダウンロードしようとしてしまう.

 違う, そうじゃない.

 

 151204_02

  スマホ(iPhone)でも同じ…

 

 

.htaccessの中身

  今記述しているのは以下になってます.

 

<Files ~ ".(gif|jpe?g|png|ico|otf|ttf|eot|woff)$">
Header set Cache-Control "max-age=2592000, public"
</Files>

<Files ~ ".(css|js|html|gz)$">
Header set Cache-Control "max-age=259200, public"
</Files>
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary

#キャッシュ設定
ExpiresActive On
ExpiresDefault "access plus 30 minutes"
ExpiresByType text/html "access plus 1 minute"
ExpiresByType image/jpg "access 1 week"
ExpiresByType image/jpeg "access 1 week"
ExpiresByType image/gif "access 1 week"
ExpiresByType image/png "access 1 week"
ExpiresByType text/css "access 1 week"
ExpiresByType application/x-javascript "access plus 1 week"
ExpiresByType text/javascript "access plus 1 week"
ExpiresByType application/javascript "access plus 1 week"
ExpiresByType image/x-icon "access 1 week"
</IfModule>

RewriteEngine on
RewriteRule ^index.html$ http://www.thetheorier.com/ [R=301,L]
RewriteRule ^iphone_URLscheme.html$ http://www.thetheorier.com/urlscheme/top [R=301,L]
RewriteRule ^iphone_URLscheme_A.html$ http://www.thetheorier.com/urlscheme/A [R=301,L]
RewriteRule ^iphone_URLscheme_B.html$ http://www.thetheorier.com/urlscheme/B [R=301,L]
RewriteRule ^iphone_URLscheme_C.html$ http://www.thetheorier.com/urlscheme/C [R=301,L]
RewriteRule ^iphone_URLscheme_D.html$ http://www.thetheorier.com/urlscheme/D [R=301,L]
RewriteRule ^iphone_URLscheme_E.html$ http://www.thetheorier.com/urlscheme/E [R=301,L]
RewriteRule ^iphone_URLscheme_F.html$ http://www.thetheorier.com/urlscheme/F [R=301,L]
RewriteRule ^iphone_URLscheme_G.html$ http://www.thetheorier.com/urlscheme/G [R=301,L]
RewriteRule ^iphone_URLscheme_H.html$ http://www.thetheorier.com/urlscheme/H [R=301,L]
RewriteRule ^iphone_URLscheme_I.html$ http://www.thetheorier.com/urlscheme/I [R=301,L]
RewriteRule ^iphone_URLscheme_J.html$ http://www.thetheorier.com/urlscheme/J [R=301,L]
RewriteRule ^iphone_URLscheme_K.html$ http://www.thetheorier.com/urlscheme/K [R=301,L]
RewriteRule ^iphone_URLscheme_L.html$ http://www.thetheorier.com/urlscheme/L [R=301,L]
RewriteRule ^iphone_URLscheme_M.html$ http://www.thetheorier.com/urlscheme/M [R=301,L]
RewriteRule ^iphone_URLscheme_N.html$ http://www.thetheorier.com/urlscheme/N [R=301,L]
RewriteRule ^iphone_URLscheme_O.html$ http://www.thetheorier.com/urlscheme/O [R=301,L]
RewriteRule ^iphone_URLscheme_P.html$ http://www.thetheorier.com/urlscheme/P [R=301,L]
RewriteRule ^iphone_URLscheme_Q.html$ http://www.thetheorier.com/urlscheme/Q [R=301,L]
RewriteRule ^iphone_URLscheme_R.html$ http://www.thetheorier.com/urlscheme/R [R=301,L]
RewriteRule ^iphone_URLscheme_S.html$ http://www.thetheorier.com/urlscheme/S [R=301,L]
RewriteRule ^iphone_URLscheme_T.html$ http://www.thetheorier.com/urlscheme/T [R=301,L]
RewriteRule ^iphone_URLscheme_U.html$ http://www.thetheorier.com/urlscheme/U [R=301,L]
RewriteRule ^iphone_URLscheme_V.html$ http://www.thetheorier.com/urlscheme/V [R=301,L]
RewriteRule ^iphone_URLscheme_W.html$ http://www.thetheorier.com/urlscheme/W [R=301,L]
RewriteRule ^iphone_URLscheme_X.html$ http://www.thetheorier.com/urlscheme/X [R=301,L]
RewriteRule ^iphone_URLscheme_Y.html$ http://www.thetheorier.com/urlscheme/Y [R=301,L]
RewriteRule ^iphone_URLscheme_Z.html$ http://www.thetheorier.com/urlscheme/Z [R=301,L]
RewriteRule ^iphone_URLscheme_symbol.html$ http://www.thetheorier.com/urlscheme/symbol [R=301,L]
RewriteRule ^iphone_URLscheme_ka.html$ http://www.thetheorier.com/urlscheme/ka [R=301,L]
RewriteRule ^iphone_URLscheme_sa.html$ http://www.thetheorier.com/urlscheme/sa [R=301,L]
RewriteRule ^iphone_URLscheme_ta.html$ http://www.thetheorier.com/urlscheme/ta [R=301,L]
RewriteRule ^iphone_URLscheme_na.html$ http://www.thetheorier.com/urlscheme/na [R=301,L]
RewriteRule ^iphone_URLscheme_ha.html$ http://www.thetheorier.com/urlscheme/ha [R=301,L]
RewriteRule ^iphone_URLscheme_ma.html$ http://www.thetheorier.com/urlscheme/ma [R=301,L]
RewriteRule ^iphone_URLscheme_ya.html$ http://www.thetheorier.com/urlscheme/ya [R=301,L]
RewriteRule ^iphone_URLscheme_ra.html$ http://www.thetheorier.com/urlscheme/ra [R=301,L]
RewriteRule ^iphone_URLscheme_wa.html$ http://www.thetheorier.com/urlscheme/wa [R=301,L]
RewriteRule ^urlscheme_sub.html$ http://www.thetheorier.com/urlscheme/urlscheme_sub [R=301,L]
RewriteRule ^urlscheme_detail.html$ http://www.thetheorier.com/urlscheme/detail [R=301,L]
RewriteRule ^prof.html$ http://www.thetheorier.com/prof [R=301,L]

 

  ググりまくって「多分こういう感じか…」と真似ただけなので詳しくはわかりません…

 それこそ301リダイレクトの記述もこれで正しいのかすら分かってません(爆)

 

 

.htmlを付ければイケる?

  ダメだったのも良いヤツも, 末尾に「.html」を付ければアクセスできるみたい.

 

 例えば http://www.thetheorier.com/urlscheme/A.html でアクセスしてみてください, 大丈夫なはずです.

 

  でも折角だから.html無しでアクセス出来たい…そもそもこれが付くのと付かないのでどう違うのかも分からない…

 

 

  正直お手上げです, 分かる人おられたら教えてください…

 

 やっぱアレかな?Googleのインデックスが終わってないとかそういうことなのかな?

 こういうのに全く慣れてないので本当に混乱してます.

 ググったの見ても自分のでその通りにいかないから実際やんないと分かんないし, やったらやったでこれは…

 

 ダメなら諦めて.html付きでリンク直すしかないのかなぁ…

 

http://www.thetheorier.com/index.html

 

サイトトップも.htmlまで付けてみた, これでもダメか…

 

 

結局

 .htmlを付けたらあっさりだった.

 やっぱりhtmlの有無がトリガだから, そういうものということか.