Redirect URLs

From e107 Wiki

Jump to: navigation, search

Contents

A simple hack for redirecting generated URLs

Suppose you have a dynamically generated page (e.g. a_page.php?x.2) and you want to redirect it to a static page. A simple approach is to do the following:

Create your new page

Create a custom page in e107_admin/cpage.php.

Add the hack

Hack the core code by adding the PHP heading code: Warning - this is a hack and will be overridden if you upgrade! Only proceed if you know what you're doing!

Code: a_page.php hack pseudo-code
if (the page is requested){ 
  header("location:".$tp->replaceConstants("{e_BASE}page.php?x")); exit;
}
where x is the number of the custom page you created in step 1.

Example from Content Management

Suppose you want to redirect calls to ...e107_plugins/content/content.php?cat.1 The content.php code contains the following to parse the URL into the $qs array:

Code: content.php hack
//existing
if(e_QUERY){
	$qs = explode(".", e_QUERY);

	if(is_numeric($qs[0])){
		$from = array_shift($qs);
	}else{
		$from = "0";
	}
}

add the following hack:

//add following hack
if( $qs[0] == "cat" && $qs[1] == "1" ){header("location:".$tp->replaceConstants("{e_BASE_constant}page.php?3")); exit;}

where page.php?3 is a custom page created in e107 admin.

Personal tools