Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force internationalization #54

Closed
hyperrjas opened this issue May 8, 2013 · 6 comments
Closed

force internationalization #54

hyperrjas opened this issue May 8, 2013 · 6 comments

Comments

@hyperrjas
Copy link

routes.rb

MyApp::Application.routes.draw do
  scope '(:locale)' do
    #my resources here...
  end
end

I have languages: en, es, ar, de...etc, and urls:

mydomain.com/en/blog, mydomain.com/es/users, mydomain.com/de/products...etc

How force to https all urls with this locales and specify an action or a controller?

Thank you!

@tobmatth
Copy link
Owner

tobmatth commented May 8, 2013

Hey,

i'm not sure i get your point. If you need to force SSL for all paths, just use Rack::SslEnforcer without any additional parameters. If you want to force SSL for e.g. /:locale/blog and /:locale/users use something like this:

config.middleware.use Rack::SslEnforcer, :only => [%r{^/\w/blog/, %r{^/\w/users/}]

HTH
Tobi

@hyperrjas
Copy link
Author

Thank you very much! that is working fine.

However I'm using this gem https://github.com/tylerhunt/rack-canonical-host for redirect al requests from http://mydomain.com to http://www.mydomain.com.

So, If I write in browser url: www.mydomain.com the website is not securized (it is not redirected to https://www.mydomain.com).

How can redirect all request from www.mydomain.com to https://www.mydomain.com ?

Thank you very much again!

@tobmatth
Copy link
Owner

tobmatth commented May 8, 2013

/edit: forget about this.

Could you point pout which paths you need to secure and what your current constraints look like?

@hyperrjas
Copy link
Author

Thank you @tobmatth, I have uninstalled rack-canonical-host gem and I have added in my application.rb file:

config.middleware.use Rack::SslEnforcer, :redirect_to => 'https://www.mydomain.com'

and I have the same problem :(.

If I write in browser url: www.mydomain.com is not redirected to https://www.mydomain.com.

However if I write in browser url mydomain.com, the redirection is working fine and it's redirected to https://www.mydomain.com

How can I redirect all www to https://www.mydomain.com?

Thank you very much for your help!

@rymai
Copy link
Collaborator

rymai commented May 14, 2013

Hi @hyperrjas, you can simply use:

config.middleware.use Rack::SslEnforcer

and every HTTP requests will be redirected to HTTPS. Also, you should put Rack::SslEnforcer before Rack::CanonicalHost.

@rymai
Copy link
Collaborator

rymai commented Sep 6, 2013

Closing this due to non-response. Feel free to re-open if your issue is not resolved. Thanks!

@rymai rymai closed this as completed Sep 6, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants