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?

  • 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
    Aug 21, 2014 at 14:00
  • hey @carlcs, how do you mean?
    – Salles
    Aug 21, 2014 at 14:10
  • 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
    Aug 21, 2014 at 14:13
  • @carlcs These URLs are gonna be submitted by users via a front end form, so not by me actually ;)
    – Salles
    Aug 21, 2014 at 14:29
  • Yeah, but that makes no difference.
    – carlcs
    Aug 21, 2014 at 14:38

2 Answers 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
    <a href="{{ link.myLinkUrl }}">{{ link.title }}</a>

{% endfor %}
  • Ah it just hit me, you're right. They way I was doing was dumb :) Thanks @carlcs!
    – Salles
    Aug 21, 2014 at 15:03

Use this redirect tag in the template of your entries. Without any plugin! :)

{% redirect entry.myUrlFieldName %}
  • Hey @carlcs, maybe I haven't been clear enough... this will redirect all entries to the same URL?
    – Salles
    Aug 21, 2014 at 14:01
  • No. It'd redirect to the url entered into a custom field with the name myUrlFieldName, @Salles.
    – carlcs
    Aug 21, 2014 at 14:02
  • Ok, thank you! :)
    – Salles
    Aug 21, 2014 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.