I've got a client who wants to use short URLs of dynamic entries for marketing literature

So clientdomain.com/events/event-type/full-event-name

Would be clientdomain.com/short-event-name

I've been setting up redirects manually within the htaccess file, but does anyone know of a better way? I can see several plugins to do it but can anyone recommend one?

Thanks for any help!


Detour Pro is an option for this, especially since it provides you with a bit of reporting on each URL redirect. However, it's meant as an alternative to doing 301 and 302 redirects in htaccess - not sure if it would be the best option for URL shortening. Another option is DM Shortee, which is more strictly a URL shortening service and not a redirect tool (same effect to the user, but potentially different effect from a search engine perspective).

  • Thanks. I'm not sure if it's technically the 'correct' thing to do, but I've decided to use this. The URL shortening wasn't right for this project as it would need an extra segment.
    – Andrew
    Sep 9 '13 at 16:45

I don't think there would be need for URL redirects if you can create such type of URLs for dynamic entries. If so you might use Structure or EE's Pages module and submit the URLs of your preference while editing/publishing an entry.

  • Unfortunately the client requested this after the site went live, so using Structure isn't an option for this project. All the entries are dynamic - ie the layout of the page is triggered by the URL segment. So it's not possible to use Pages either.
    – Andrew
    Sep 9 '13 at 16:49

Because you can't set the redirect to 301, on the default redirect variable, you should use a mix of query module and php.

To keep the code more manageable, I gonna add one segment to your short URL. Let's say, "s":


You can set a short domain to use the same directory folder, if you want to:


On the index.html of the directory "s", set the PHP parsing to output.

Let's say, your short-event-name has the field_id 10.

    SELECT exp_channel_data.entry_id, exp_channel_titles.url_title
    FROM exp_channel_data
    JOIN exp_channel_titles on exp_channel_data.entry_id = exp_channel_titles.entry_id
    WHERE field_id_10 = "{segment_2}"
    LIMIT 1;"
    {if no_results OR segment_3}
$permalink = 'http://clientdomain.com/events/event-type/{url_title}';

//  header('Status: 301 Moved Permanently',false,301); //enable this line after test
//  header('Location: '.$permalink);  //enable this line after test
    echo('{entry_id}');  // comment this line after test
    echo('Location: '.$permalink); // comment this line after test
    die(); //comment this line after test

You can have conditionals and to use the {channel_url} URL to create short links to all channels. I use to create mine as shortdoma.in/s/entry_id, to avoid the risk of duplicated short_url_titles.


For a simple solution I recommend using the Pages module in conjunction with a "Redirects" Channel. The Pages module will allow you to create an entry with whatever URI you want to "listen" for and redirect. The entry will store the URL you want to redirect to in a custom field.

1) Set up your Redirects channel with a custom field to hold the URL to redirect to (eg redirect_url).

2) Create a redirect template (I use pages.group/_redirect.html, but name it what you like). Set it as the default Pages module template for entries in this channel and add the following to it:


    {exp:http_header status="301" location="{redirect_url}" terminate="yes"}


This method uses the HTTP Header add-on to handle the redirect. It works great with a redirect URI string (more useful since it is portable across environments) or a URL.

  • It's a good idea, too! I liked it! Thanks!
    – Sobral
    Sep 9 '13 at 15:14
  • Great idea, but from the clients point of view it's better to have all the URLs listed on one admin panel.
    – Andrew
    Sep 9 '13 at 16:46
  • Yeah, just depends on how many redirects you're going to end up working with and on the client. This has worked great as a simple solution for me on a few sites, but Detour Pro is certainly a more robust solution!
    – Alex Kendrick
    Sep 9 '13 at 16:55

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.