Save page state for index.php and redirect ajax requests correctly