jopotts (owner)

Revisions

  • 34c068 Thu Feb 19 10:34:23 -0800 2009
gist: 67043 Download_button fork
public
Public Clone URL: git://gist.github.com/67043.git
Ruby
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# From here:
# http://groups.google.com/group/phusion-passenger/browse_thread/thread/5e019e5d65beb54f
 
def trim_www
  if request.subdomains.first == "www"
    if request.subdomains == ["www"]
      redirect_to "#{request.protocol}#{request.domain}#{request.port_string}#{request.path}"
    else
      subdomains = request.subdomains.shift.join(".")
      subdomains << "." unless subdomains.blank?
      redirect_to "#{request.protocol}#{subdomains}#{request.domain}#{request.port_string}#{request.path}"
    end
  end
end