<p>Instead of using a redirect, what about using the saved URLs directly with your links?</p>

<p>Let's say it's a channel with the handle <code>myExternalLinks</code> where you collect the links. The actual URL is entered into a field with the handle <code>myLinkUrl</code>.</p>

<p>This is the template code to list the links:</p>

<pre><code>{% set links = craft.entries.section('myExternalLinks') %}

{% for link in links %}

    {#
     # Link to the URL entered into `myLinkUrl` instead of
     # linking to `entry.getUrl()` and then using a redirect on that entry template
     #}
    &lt;a href="{{ link.myLinkUrl }}"&gt;{{ link.title }}&lt;/a&gt;

{% endfor %}
</code></pre>

CC BY-SA 3.0
2014-08-21T15:03:19.573Z
Ah it just hit me, you're right. They way I was doing was dumb :) Thanks @carlcs!
Salles
CC BY-SA 3.0
2014-08-21T14:50:16.570Z
2014-08-21T14:50:16.570Z
carlcs
<p>Use this <a href="http://buildwithcraft.com/docs/templating/redirect" rel="nofollow"><code>redirect</code></a> tag in the template of your entries. Without any plugin! :)</p>

<pre><code>{% redirect entry.myUrlFieldName %}
</code></pre>

CC BY-SA 3.0
2014-08-21T14:01:40.477Z
Hey @carlcs, maybe I haven't been clear enough... this will redirect all entries to the same URL?
Salles
CC BY-SA 3.0
2014-08-21T14:02:55.677Z
No. It'd redirect to the url entered into a custom field with the name `myUrlFieldName`, @Salles.
carlcs
CC BY-SA 3.0
2014-08-21T14:05:07.990Z
Ok, thank you! :)
Salles
CC BY-SA 3.0
2014-08-21T13:54:57.867Z
2014-08-21T13:54:57.867Z
carlcs
<p>Say I have a custom field "URL" for each entry and I want them to be redirected to these specific URLs instead of Craft's.</p>

<p>Similar to WordPress "Page Links To" plugin. <a href="http://wordpress.org/plugins/page-links-to/" rel="nofollow">http://wordpress.org/plugins/page-links-to/</a></p>

<p>Can I do this in Craft?</p>

CC BY-SA 3.0
2014-08-21T14:00:46.553Z
Where do you list the links to these entries. Wouldn't it make sense to load the URL from that custom field into that list, instead of using 302 redirects?
carlcs
CC BY-SA 3.0
2014-08-21T14:10:35.017Z
hey @carlcs, how do you mean?
Salles
CC BY-SA 3.0
2014-08-21T14:13:43.507Z
What you're now doing is using a link `<a href="entryUrl"...` to link to that entry and then the visitor is redirected from that entry page to the URL you actually want him to see. My question is, why don't you use that URL in the actual link?
carlcs
CC BY-SA 3.0
2014-08-21T14:29:33.360Z
@carlcs These URLs are gonna be submitted by users via a front end form, so not by me actually ;)
Salles
CC BY-SA 3.0
2014-08-21T14:38:26.600Z
Yeah, but that makes no difference.
carlcs
<entries><url><redirect><redirection>
How to redirect an entry's URL to a specific URL?
# How to redirect an entry's URL to a specific URL?

(Asked by: username_0 on 2014-08-21)

Say I have a custom field "URL" for each entry and I want them to be redirected to these specific URLs instead of Craft's.

Similar to WordPress "Page Links To" plugin. <http://wordpress.org/plugins/page-links-to/>

Can I do this in Craft?

**Tags:** entries, url, redirect, redirection
> **Comments:**
> **username_1**: Where do you list the links to these entries. Wouldn't it make sense to load the URL from that custom field into that list, instead of using 302 redirects?  
> **username_0**: hey @carlcs, how do you mean?  
> **username_1**: What you're now doing is using a link `<a href="entryUrl"...` to link to that entry and then the visitor is redirected from that entry page to the URL you actually want him to see. My question is, why don't you use that URL in the actual link?  
> **username_0**: @carlcs These URLs are gonna be submitted by users via a front end form, so not by me actually ;)  
> **username_1**: Yeah, but that makes no difference.  

---

## 2 answers

### Answer by username_1 on 2014-08-21. Score: 2

Instead of using a redirect, what about using the saved URLs directly with your links?
Let's say it's a channel with the handle myExternalLinks where you collect the links. The actual URL is entered into a field with the handle myLinkUrl.
This is the template code to list the links:
{% set links = craft.entries.section('myExternalLinks') %}

{% for link in links %}

    {#
     # Link to the URL entered into `myLinkUrl` instead of
     # linking to `entry.getUrl()` and then using a redirect on that entry template
     #}
    {{ link.title }}

{% endfor %}

> **Comments:**
> **username_0**: Ah it just hit me, you're right. They way I was doing was dumb :) Thanks @carlcs!  

---

### Answer by username_1 on 2014-08-21. Score: 1

Use this redirect tag in the template of your entries. Without any plugin! :)
{% redirect entry.myUrlFieldName %}

> **Comments:**
> **username_0**: Hey @carlcs, maybe I haven't been clear enough... this will redirect all entries to the same URL?  
> **username_1**: No. It'd redirect to the url entered into a custom field with the name `myUrlFieldName`, @Salles.  
> **username_0**: Ok, thank you! :)  

---

