Rcoder
Rcoder

Reputation: 11

External URL re direction issue IN Rails 2

I have a requirement where in I want to redirect to an external Url Here is my code in routes.rb

map.connect "/myapp/:someparam" , :controller => "foocontroller" , :action => "redirect_to_external_url"

In my foo controller i have this action

def redirect_to_external_url redirect_to "http://externalurl.com/#{params[:someparam]}.html" end

which will redirect to the external url

The problem That I am facing is After redirecting, The browser shows "http://externalurl.com/bar.html whereas I want the browser to show "/myapp/bar" url (ex http://mydomain.com/myapp/bar) for seo purpose.

Any idea on how this can be achieved in rails ? The Rails version that I am using is 2.3.4

Upvotes: 1

Views: 496

Answers (1)

reto
reto

Reputation: 16732

  1. Action can only be a method in your controller, not an external url (see Routing guide)

  2. When you redirect using redirect_to and use an externel url (as in your example) the router.rb wont even be involved

  3. displaying an external page under your own url is not that easy, one way to the that would be using frame forwarding or with a reverse proxy.

Does 'external_url? belong to yourself? or is it from somebody else?

Upvotes: 1

Related Questions