title: How to retrieve the `scheme://domain` part of an URL without including subdomains?
body: <p>I am using Ruby on Rails 3.0.10 and I would like to retrieve the <code>scheme://domain</code> part of an URL without including the subdomain part. That is, if I have the following URL</p>
  
  <pre><code>http://www.sub_domain.domain.com
  </code></pre>
  
  <p>I would like to retrieve</p>
  
  <pre><code>http://www.domain.com
  </code></pre>
  
  <p><strong>How can I do that</strong> (should I use a regex?)<strong>?</strong></p>
  
  <hr>
  
  <p><strong>UPDATE</strong></p>
  
  <p><code>@mu is too short</code> rightly said in his\her comment (that made ​​me think...):</p>
  
  <blockquote>
    <p>You misunderstand. www.ac.uk is meaningless, the base domain for
    Oxford is ox.ac.uk; the ac.uk part means "academic UK" and is,
    semantically, one component. A few other countries have similar naming
    schemes.</p>
  </blockquote>
  
  <p>So, the update question is:</p>
  
  <p><strong>How can I iterate over an URL</strong> (for example <code>http://www.maths.ox.ac.uk/</code>) as made in the following steps <strong>so to delete <em>progressively</em> subdomain parts until the last?</strong></p>
  
  <pre><code>http://www.maths.ox.ac.uk/ # Step 0 (start)
  http://www.ox.ac.uk/       # Step 1
  http://www.ac.uk/          # Step 2 (end)
  </code></pre>