# Link\_to external link

**URL:** <https://www.ruby-forum.com/t/link-to-external-link/58663>\
**Category:** Rails\
**Created:** [April 24, 2006, 5:27pm UTC](https://www.ruby-forum.com/t/link-to-external-link/58663 "2006-04-24T17:27:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [April 24, 2006, 5:27pm UTC](https://www.ruby-forum.com/t/link-to-external-link/58663/1 "2006-04-24T17:27:53Z")

</div>

I have searched through the api several times through and can’t seem to  
find this.

\<%= link\_to ‘Help’,  
{:url =\> ‘[https://www.example.com/page?AppServeHelp](https://www.example.com/page?AppServeHelp)’},  
{:target =\> “\_new”} %\>

but this doesn’t work as it still prepends the current server/controller  
space on the url itself.

How do I accomplish this?

Thanks

Craig

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [April 24, 2006, 5:37pm UTC](https://www.ruby-forum.com/t/link-to-external-link/58663/2 "2006-04-24T17:37:17Z")

</div>

try

link\_to ‘Help’,‘[https://www.example.com/page?AppServeHelp](https://www.example.com/page?AppServeHelp)’,{:target =\>  
“\_new”}

On Monday, April 24, 2006, at 8:26 AM, Craig W. wrote:

> How do I accomplish this?
> 
> Thanks
> 
> Craig
> 
> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

\_Kevin

---

<div class="post-metadata">

**Author:** ![craigrails](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/c2a13f/32.png) [@craigrails](https://www.ruby-forum.com/u/craigrails)\
**Post date:** [April 24, 2006, 7:17pm UTC](https://www.ruby-forum.com/t/link-to-external-link/58663/3 "2006-04-24T19:17:02Z")

</div>

Hi Craig,

I’m not sure that you’d want to use link\_to in this case. It seems like  
the  
purpose of link\_to and url\_for, which it’s based on, is to take  
advantage of  
the mappings you’ve created in routes.rb .

However, you may also want to try the following options, which I copied  
from  
the url\_for documentation

# :only\_path - if true, returns the absolute URL (omitting the protocol,

host name, and port)

# :host - overrides the default (current) host if provided

# :protocol - overrides the default (current) protocol if provided

I hope this helps!  
Daniel
