look in your /system/application/errors/ and find the error_404.php and put this (edited to match your site of course)

<?php
header(“HTTP/1.1 404 Not Found”);
header(“location:http://www.tldomain.com/index.php?/controller/sitemap/404″);
?>

So when the 404 page loads the 404 still gets logged by apache etc… but once that happens it gets rushed of to (in this case) the site map. The 404 variable tells the controller method in this case the site map to display a this page cannot be found message.

This is for debugging only. Ok, again…. this is for debugging only. If you use this REMOVE it once it goes live. At worst you forget to add the tag that clears the log file each time and it bloats horribly and your site gets progressively slower and slower, then your server will crash, you’ll get fired and end up homeless. But if you remove it when your done it’s pretty handy.

This goes in a helper file of your choosing and make sure you load it:

$this->load->helper('the_helper_where_you_put_this_code');

Then put this in the helper file you loaded

if ( ! function_exists('app_log')) {

function app_log($arg) {

// this is your log file, so I referenced it by viewing
// domain.com/applog.htm
$log = './applog.htm';

// to empty the file and start over the first call should begin with init_log
if( preg_match(“/^init_log/”, $arg) ) {

// writes the the file name and whatever the arg is at the start of the file
if (!write_file($log, ''.$arg, 'w') ) {

// or dies
die( 'Unable to write to log file');

}

} else {

// adds whatever the $arg is to the end of the file
if ( ! write_file($log, ''.$arg, 'a+')) {

// or dies
die( 'Unable to write to log file');

}

}

}

}

To use the helper:

app_log('init_log -> Whatever you want goes here');

I usually make the above call in the constructor, then after that in your methods whatever you want to track use:

app_log('blah blah blah');

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Here is roughly how I did that:

http://www.jamesborder.local/URLRequest.php (your url should be wherever your data is)

<?php

// create an array to put your junk in… then put it there
$variablesArray = array();
$variablesArray['var1'] = “foo”;
$variablesArray['var2'] = “bar”;

// let php build a nice string for you
$variablesArrayString = http_build_query($variablesArray);

echo $variablesArrayString;
// var1=foo&var2=bar

?>

-=-=-=-=-=-=-=-=-=-

Here is roughly what is in the .fla

// build your request…. your url/file will go here
var request:URLRequest = new URLRequest(“http://www.jamesborder.local/URLRequest.php”);
request.method = URLRequestMethod.GET;

// create
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, onCompleteHandler);
loader.load(request);

function onCompleteHandler(event:Event) {

trace(“completeHandler(“+event+”)”);
var var1 = event.target.data.var1;
var var2 = event.target.data.var2;

trace ('variable one: ' + var1);
trace ('variable two: ' + var2);

}

© 2012 James Border Suffusion theme by Sayontan Sinha