Nov 02

How to fix broken URLs in ExpressionEngine

2006 at 08.08 pm posted by Veerle

First of all, I’m back! The move went well. However, it’s a bit chaotic here. A lot of boxes still need to be unpacked. I tell ya this takes more then a Spring cleaning :) I’ve gathered too much stuff over the past 12 years. Oh well, at least I am connected already :) I thought this was a good moment to share a small but useful EE tip. Before ExpressionEngine version 1.5 there was this problem when people didn’t enter the full URL of an article page, EE loaded a rather messy page. Since 1.5 it’s easy to make sure all broken URLs don’t get a 404 error page or a messy page.

This problem often occurred when people clicked on a very long link from the e-mail you receive when you are subscribed to the comments of an article. If the URL is very long chances are that the link is broken because it's broken into 2 lines. By adding the require_entry="yes" parameter in all the necessary exp tags of the article template page we can warn the user that the URL is incomplete or that the requested URL can't be found.

How to use Expression Engine's require_entry parameter

This parameter tells the weblog tag that the URL should contain a valid URL title or ID. If this is not the case and the URL is broken the weblog tag won't show any data. In this situation we can use the "if no_results" conditional to show the user a message to inform what is happening and maybe refer to the archive page.

the use of Expression Engine's require_entry parameter

Make sure you add this parameter in all necessary exp tags of the template. For example also in the "exp:comment:entries" tag. This way no content will be shown. The only exp tag I left out is the "exp:comment:form" tag. It is not needed in this tag.

Hope this short EE tip is a useful one.


12served

gravatar

1

permalink this comment George Ornbo Thu Nov 2, 2006 at 09.27 pm

Not sure whether this code will come out but it is also useful to serve a 404 page based on the require_entry variable. You can do this by turning on PHP in templates and then including a file if the entry is not valid.

{if no_results}
<?php require_once($_SERVER['DOCUMENT_ROOT']."/404/index.php"); exit; ?>
{/if}

You can offer the user helpful information on the 404 page and it keeps Search Engines up to date with any pages that have been removed from you site.

In the 404 page include this before the head and this will tell search engines the page is not found:

header("HTTP/1.0 404 Not Found");

gravatar

2

permalink this comment Lea Thu Nov 2, 2006 at 11.10 pm

This is an amazing tip. Thanks!


gravatar

3

permalink this comment edit-undo Thu Nov 2, 2006 at 11.31 pm

Nice tip Veerle! Thanks. :)


gravatar

4

permalink this comment Mariny Fri Nov 3, 2006 at 08.10 am

Yeh, every move is hard, but useful,as you sleep off all your old, not needed stuff that is just gathered on garret or another place.But often move is also not so good. You just get accustomed with the place and after a while you have to move. I have this problem now.I’ve lived for 18 years at one place,4 years I roved from one place to another and now I have to move completely to another town. :( but I want to live in New Zealand…


gravatar

5

permalink this comment Solar Fri Nov 3, 2006 at 11.48 am

My experience tells me that better take 2 days for a break and unpack all boxes, because they can be packed for the months


gravatar

6

permalink this comment Daus Fri Nov 3, 2006 at 03.57 pm

Good article


gravatar

7

permalink this comment e-man Sun Nov 5, 2006 at 09.44 am

Wow, what a great tip!
I learn something new about EE every day, thanks Veerle!


gravatar

8

permalink this comment Kev Sun Nov 5, 2006 at 03.40 pm

Nice one!

:)


gravatar

9

permalink this comment Tazz Mon Nov 6, 2006 at 09.42 pm

I’m downloading the core version to try it out.  Still in two minds if I should go for the familiar Wordpress or the Expression Engine. But your posts got me really interested to try Expression Engine.  Thanks.


gravatar

10

permalink this comment Erika Tue Nov 7, 2006 at 01.16 am

Very nice Veerle! I’m still trying to figure out how EE works...once it’s ready, you’ll be the first one to know! ;-)


gravatar

11

permalink this comment Plastic Man Sun Nov 12, 2006 at 06.53 pm

Great! Thats exactly what I was looking for. Thanks!


gravatar

12

permalink this comment bestann Tue Nov 14, 2006 at 01.17 pm

Your site is beautiful! It is easy to read and understand your very useful tips even for me, the foreigner from Russia.

Thank You! Waiting for the new posts....



Commenting is not available in this weblog entry.

Flickrness

buy something from my Amazon wishlist