Personal tools
Document Actions

どちらでも同じURL

by Days posted at 2006-05-31 23:51 last modified 2006-05-31 23:51

パソコンのブラウザからでも、ケータイからでも同じURLを使ってアクセスさせ、でも表示する内容はそれぞれの端末に合わせたもの、というふうにするには、サーバ側で工夫が必要になる。
例えば、IISでASP (VBScript) を使ってやろうとすると、こんな感じ。

<%
agent = request.servervariables("http_user_agent")

if instr(agent, "DoCoMo") <> 0 then
response.redirect("http://www.somewhere.com/docomo/")
elseif instr(agent, "J-PHONE") <> 0 then
response.redirect("vodafone/")
elseif instr(agent, "Vodafone") <> 0 then
response.redirect("vodafone/")
elseif instr(agent, "UP.Browser") <> 0 then
response.redirect("au/")
else
response.redirect("/index.html")
end if
%>

デフォルトドキュメントの設定で、default.asp を default.htmより優先されるようにしておいて、default.asp にこのスクリプトを書いておく。PC向けのサイトは、index.html以下、ケータイ向けのサイトは、docomo, vodafone, auそれぞれのディレクトリに入れておく。
DoCoMoの一部機種では、相対パスでのリダイレクトが効かないそうなので、DoCoMo向けだけ相対パス必須。

難点は、キャリアの名前が変わると、それに応じてたぶんこのスクリプトも変えなければならないことだ。ケータイサイトの賞味期限は、短い。

Category(s)
仕事の周辺

Softbank

Posted by days at 2007-01-11 23:24

ソフトバンクケータイはUAが新しくなります。
"elseif instr(agent, "Softbank") <> 0 then" とか、追加してやってください。

Add comment

You can add a comment by filling out the form below. Plain text formatting.

(Required)
(Required)
(Required)
(Required)

« September 2010 »
Su Mo Tu We Th Fr Sa
      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    
Recent entries
Damming Tibet's Yarlung Tsangpo days 2010-09-04
Mining Lead to Standoffs with Tibetans days 2010-08-31
Tibetan Petitioners Killed in Palyul days 2010-08-25
Monks Protest Amid Festival Tensions days 2010-08-17
Life Sentence for Yak Hotel Owner days 2010-08-15
Tashikaraura days 2010-08-14
Truth in Drugchu days 2010-08-10