How to mask my landing page when user not signed in?
I got my web platform built on ruby on rails at https://example.com
My landing and about pages are hosted in a Wordpress in other host at https://examplecms.com.
What i would like to achieve is to make users to visit https://example.com get masked https://examplecms.com except when they are logged in as my platform's dashboard is routed in the root path /.
What i am trying to avoid is the user to see in the URL https://examplecms.com.
I've tried so far a couple of tricks:
I have been thinking into doing at proxy server level, using .htaccess or even using DNS strategies but i can't come up for a solution to these strategies to detect when the user is signed in or not?
Any ideas?
Thanks
Update: Stack:
You can use http://nginx.org/r/proxy_pass to silently redirect the user to a different page, without changing the URL that's shown to the user within the Location
field of the browser.
To check whether the user is logged in, you can install an error handler via http://nginx.org/r/error_page to redirect the user only if your normal page returns an error (eg, if the normal proxy_pass
results in a 403 Forbidden
response, then redirect the user's request to the alternative proxy_pass
upstream as per the error handler).
What you're looking for is route scopes. I'm using Devise for authentication, which provides helpers for doing what you want, but I have no doubt you can adjust for your needs. When a user hits any page on the site, they are automatically redirected to the login. If they are logged in, they are redirected to the homepage/URL they typed in.
authenticated :user do
root to: 'titles#index'
end
devise_scope :user do
root to: 'devise/sessions#new'
end
Create a subdomain
For your WordPress hosted web content, you could create a very simple subdomain on your hosting provider like so blog.example.com
that is alias to examplecms.com
Use Device Gem for Authentication
You can use the device gem to authenticate the user and route the user to the subdomain. When the user hits the /root_path.
链接地址: http://www.djcxy.com/p/850.html上一篇: 需要合并数组中的值
下一篇: 用户未登录时如何屏蔽我的登录页面?