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)

« January 2009 »
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 31
Recent comments
Re:re: Quake Hits Damshung ディディ 2008-10-07
Re:Ooma Ferry Route Suspension にだて 2008-09-10
Re:Woeser Intimidated in Lhasa Woeser Dawa 2008-08-26
新華網で続報 days 2008-08-06
130件のコメントスパムを削除 days 2008-07-31
Re:A Political Prisoner ディディ 2008-07-25
Re:Love from Around the World ディディ 2008-07-08