私のウェブサイトでは、単一のドメインからさまざまなリソースを使用しています。たとえば、次のようになります。
http://static.example.com/javascript/common.js
http://static.example.com/javascript/common.css
http://static.example.com/javascript/menu/menu.js
http://static.example.com/javascript/menu/menu.css
http://static.example.com/images/1804/logo/02000100.jpg
http://static.example.com/images/1804/headers/main/09400060.png
http://static.example.com/images/1804/headers/home/1101/06900200-01.jpg
http://static.example.com/images/1804/headers/home/1101/06900200-02.jpg
これらの URL を数字 (0、1、2、3) にマップする非常に単純な文字列ハッシュ関数が必要です。アルゴリズムは決定論的で統一されている必要があります。質問 PHP にタグを付けましたが、一般的な回答は受け入れられます。
なぜこれが必要なのか、ご想像のとおりです。たとえば、次のように URL を変更する予定です。
http://0.static.example.com/javascript/common.js
http://2.static.example.com/javascript/common.css