<?php

$iq_var = explode("/", $_SERVER["PHP_SELF"]);
//print_r($iq_var);

$iq_var[2] = trim($iq_var[2]);

if(isset($iq_var[2]) && trim($iq_var[2]) != NULL && strcmp($iq_var[1], "Interview-Questions") == 0 )
{
	if(preg_match('/\.html$/', $iq_var[2]))
		$findcatname = str_ireplace(".html", "", $iq_var[2]);
	else
		$findcatname = 	$iq_var[2];
	
	$findcatname = strtolower($findcatname);
		
	include_once("./common/categories_array.php");

	for($i=0; $i<count($categories); $i++)
		if( $categories[$i][2] == $findcatname)
			$findcatno = $categories[$i][0];	
		
	if(isset($iq_var[3]) && trim($iq_var[3]) != NULL)
	{
		$findpage = trim(preg_replace('/page|\.html/', "", $iq_var[3]));
	}
	
	
	if(isset($findpage))
		$findurl = "/interview-questions/$findcatno-$findpage/$findcatname.html";
	else
		$findurl = "/interview-questions/$findcatno/$findcatname.html";
	
	//echo $findurl;
//	echo "<h1 align='center'> This URL is Moved to New Location. <br> Please Update your Bookmarks <br><br>Redirecting in a Second...... </h1>";
	
	
	header('Location: ' . $findurl, true, 301);
	
	exit();
}	
	
	
?>