Skip to navigation

Fri Jul 13th

normalise those URLs

# Normalise your URLs, yo:
# http://www.standardzilla.com/2007/07/09/dont-forget-your-trailing-slash/

TLD_LENGTH = 1

before_filter :remove_trailing_slashes
def remove_trailing_slashes
  if (uri = request.request_uri).length > 1 and uri[-1,1] == '/'
    headers['Status'] = '301 Moved Permanently'
    redirect_to uri.chop
    return false
  end
end

before_filter :no_www
def no_www
 if (bad_subdirs = %w[ww www]).any? {|s| [s]==request.subdomains(TLD_LENGTH)}
   headers['Status'] = '301 Moved Permanently'
   redirect_to :host => request.domain(TLD_LENGTH)
   return false
 end
end
Page 1 of 1

Tumble

toolmantim

I'm Tim Lucas, a web app designer and developer currently in Sydney Australia.

I run a web application design and development company Agency Rainford, present on various technical topics, snap the occasional photo, tweet my going-ons, share teh codes and post other tid-bits to the tumble.

Shoot an email to and say hello.

Powered by tumblr.com