How can I strip a subdomain if it is "www" in a Rails 3.2 application? -
i have rails 3.2 application driven subdomains:
company1.myapp.com companyn.myapp.com
some people trying this:
www.companyn.myapp.com
which yields error. how can strip out leading subdomain if it's www?
i have in app controller:
def redirect_to_subdomain_page subdomain = request.subdomain subdomain = "xyz" if subdomain.blank? or subdomain=="www" render "#{subdomain}_#{params[:action]}" end
but if go www.companyn.myapp.com
want redirect them companyn.myapp.com
. want redirect them actual url changes.
request.subdomains
should return array of subdomains like:
def redirect_to_subdomain_page subdomains = request.subdomains if subdomains.length <= 1 subdomain = subdomains.first subdomain = "xyz" if subdomain.blank? or subdomain=="www" render "#{subdomain}_#{params[:action]}" else redirect_to "http://companyn.myapp.com/#{request.fullpath}" end end
Comments
Post a Comment