简体   繁体   中英

Rails: Mapping root_url to an external url

We're using an external CMS to manage our site and I'd like to ensure that inside of our Rails app, root_url points out to that external url. Is there any way we can do this?

Something like:

root :to => "http://wwww.example.com"

You can match the root of your application like this to redirect to an external URL

#
# config/routes.rb
#

root :to => redirect("http://www.google.com/")

As @Digi_Cazter answered correctly you can do this by adding this

root :to => redirect("http://www.google.com/")

I would like to use such redirects from app only if I want specific url's to be redirected.

I would suggest you to redirect the request directly form the webserver you are using may be apache-httpd or nginx or whichever you may be using instead of passing it to app and then redirecting it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM