2012-01-26 6 views
0

現在、自分のサイトの「ルート」にいるときにクエリ文字列パラメータを追加する正しい構文は何ですか?ドメインのトップレベルにあるときにクエリ文字列パラメータを追加する正しい方法?

1) http://www.example.com/?foo=bar 
2) http://www.example.com?foo=bar 
3) http://www.example.com/&foo=bar 

私は#3が完全に間違っているが、私は1または2に不安だ私は、このシナリオに遭遇したことがありません確信している、常に、それは拡張子だとファイル名に追加されています - この奇妙なユースケースが私たちのチームに現れ、私は頭を傷つけていました。

答えて

3

数字1が唯一正しいものです。 RFC1738 3.3:

An HTTP URL takes the form: 

     http://<host>:<port>/<path>?<searchpart> 

    where <host> and <port> are as described in Section 3.1. If :<port> 
    is omitted, the port defaults to 80. No user name or password is 
    allowed. <path> is an HTTP selector, and <searchpart> is a query 
    string. The <path> is optional, as is the <searchpart> and its 
    preceding "?". If neither <path> nor <searchpart> is present, the "/" 
    may also be omitted. 
+0

ありがとうございます。迅速で簡潔で、特にRFCのリファレンスが好きです。とても有難い! – rsturim

関連する問題