Skip to content

Instantly share code, notes, and snippets.

@Caffe1neAdd1ct
Last active October 6, 2017 09:31
Show Gist options
  • Save Caffe1neAdd1ct/730144309e4a9d18d8ae10ef53430521 to your computer and use it in GitHub Desktop.
Save Caffe1neAdd1ct/730144309e4a9d18d8ae10ef53430521 to your computer and use it in GitHub Desktop.
Router for CakePHP 1.3
<?php
$path = parse_url($_SERVER["REQUEST_URI"], PHP_URL_PATH);
// If the file exists then return false and let the server handle it
if (file_exists($_SERVER["DOCUMENT_ROOT"] . $path)) {
return false;
} else {
/** makes the /manage/ area work */
if ($_SERVER["SCRIPT_FILENAME"] === $_SERVER["DOCUMENT_ROOT"] . DIRECTORY_SEPARATOR . 'index.php') {
$_SERVER['SCRIPT_NAME'] = '/';
$_SERVER['PHP_SELF'] = '/';
require_once 'index.php';
} else {
/** makes cakephp plugin asset loading work */
if (!strpos($_SERVER['SCRIPT_NAME'], '/index.php')) {
$_SERVER['SCRIPT_NAME'] = "/index.php" . $_SERVER['SCRIPT_NAME'];
}
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
$_SERVER['PHP_SELF'] = '';
$_SERVER['SCRIPT_FILENAME'] = $_SERVER['SCRIPT_NAME'];
require 'index.php';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment