Y
Y
yolutal2014-08-01 16:44:34
Ruby on Rails
yolutal, 2014-08-01 16:44:34

Elasticsearch in RoR. Get rid of the 3rd level domain. How to correctly specify paths in routes?

In general, everything is fine for the 2nd level domain. - example.com/search?utf8=✓&query=example1
The 3rd level domain requires that the query redirect to the 2nd level domain and not stay on the 3rd level domain. - foo.example.com/search?utf8=✓&query=example2
And more, how and is it worth getting rid of the parameter in the utf8=✓ request? Because I know that it is kind of like for IE old versions.
using kaminari

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
romanwb, 2014-10-21
@romanwb

For all subdomains

Rails.application.routes.draw do
  constraints subdomain: /.+/ do
    get '/(*uri)' => redirect { |params, request| "http://example.com#{request.original_fullpath}" }
  end

  root 'welcome#index'
end

For specific constraints subdomain: 'foo'
In general, maybe it makes sense to configure this in nginx?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question