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.

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
1
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");2
This is an amazing tip. Thanks!
3
Nice tip Veerle! Thanks. :)
4
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…
5
My experience tells me that better take 2 days for a break and unpack all boxes, because they can be packed for the months
6
Good article
7
Wow, what a great tip!
I learn something new about EE every day, thanks Veerle!
8
Nice one!
:)
9
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.
10
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! ;-)
11
Great! Thats exactly what I was looking for. Thanks!
12
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....