Implement a URL shortener
JavaScript (ES6), 149 bytes

u=&gt;u.split`/`.map((p,i)=&gt;i?/^\d+$/.test(p)?(+p).toString(36):p[0]:(d=p.split`.`).slice(0,-1).map((s,j)=&gt;s[l=j,0]).join``+"."+d[l].slice(1,3)).join`/`


Explanation

I made this independent of @Neil's solution but it ended up looking very similar.

u=&gt;
  u.split`/`.map((p,i)=&gt;       // for each part p at index i
    i?                         // if this is not the first part
      /^\d+$/.test(p)?         // if p is only digits
        (+p).toString(36)      // return p as a base-36 number
      :p[0]                    // else return the first letter
    :
      (d=p.split`.`)           // d = domain parts
      .slice(0,-1).map((s,j)=&gt; // for each domain part before the last
        s[l=j,0]               // return the first letter, l = index of last domain part
      ).join``
      +"."+d[l].slice(1,3)     // add the 2 letters as the final domain
  )
  .join`/`                     // output each new part separated by a slash


Test



var solution = u=&gt;u.split`/`.map((p,i)=&gt;i?/^\d+$/.test(p)?(+p).toString(36):p[0]:(d=p.split`.`).slice(0,-1).map((s,j)=&gt;s[l=j,0]).join``+"."+d[l].slice(1,3)).join`/`
&lt;input type="text" id="input" value="math.stackexchange.com/a/2231/" /&gt;
&lt;button onclick="result.textContent=solution(input.value)"&gt;Go&lt;/button&gt;
&lt;pre id="result"&gt;&lt;/pre&gt;