Skip to content

Commit

Permalink
Update .htrouter.php
Browse files Browse the repository at this point in the history
Making this simulate the .htaccess file a bit closer.
  • Loading branch information
Ultimater committed Aug 31, 2017
1 parent 2a8a72c commit 8c8faab
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion .htrouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,27 @@
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);

if ($uri !== '/' && file_exists(__DIR__ . $uri)) {
return false;
}

if ($uri !== '/' && file_exists(__DIR__ . '/public' . $uri)) {
header('Location: /public' . $_SERVER['REQUEST_URI'], true, 303);
exit;
}

if (preg_match('#(?:^/core/(?:assets|themes|uploads)(?:$|/|[?]))#', $uri)) {
return false;
}

$_GET['_url'] = $_SERVER['REQUEST_URI'];
if (preg_match('#^/core/modules/[^/]+/assets/#', $uri)) {
return false;
}

if(preg_match('#^/([^/]+)/assets/(.+)#', $uri, $m)) {
header('Location: /core/modules/' . $m[1]. '/assets/'. $m[2], true, 303);
exit;
}

$_GET['_url'] = $_SERVER['REQUEST_URI'];
require_once __DIR__ . '/public/index.php';

0 comments on commit 8c8faab

Please sign in to comment.