Rewrote to server content through index.php

This commit is contained in:
Belle Aerni 2023-01-07 17:44:16 -08:00
parent ca005bd074
commit f5844cb2cc
4 changed files with 41 additions and 12 deletions

View file

@ -1,8 +1,4 @@
RewriteEngine On
# Don't rewrite requests for files in the /Themes/*/Assets/ directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/Themes/.*/Assets/.*$
# Rewrite all other requests to index.php
RewriteRule .* index.php [L]

View file

@ -169,4 +169,15 @@ class AntCMS
$currentConfig = AntConfig::currentConfig();
return $currentConfig['SiteInfo'];
}
public function serveContent($path)
{
if (!file_exists($path)) {
$this->renderException('404');
} else {
$asset_mime_type = mime_content_type($path);
header('Content-Type: ' . $asset_mime_type);
readfile($path);
}
}
}

View file

@ -8,7 +8,7 @@
<meta name="author" content="<!--AntCMS-Author-->">
<meta name="keywords" content="<!--AntCMS-Keywords-->">
<link href="<!--AntCMS-SiteLink-->Themes/Tailwind/Assets/Dist/tailwind.css" rel="stylesheet">
<link href="<!--AntCMS-SiteLink-->Themes/Default/Assets/Dist/tailwind.css" rel="stylesheet">
<title><!--AntCMS-Title--></title>
</head>
@ -18,14 +18,22 @@
<nav class="p-3 border-gray-200 bg-gray-100 dark:bg-zinc-900 dark:border-gray-700">
<div class="container flex flex-wrap items-center justify-between mx-auto">
<a href="<!--AntCMS-SiteLink-->" class="flex items-center">
<span class="self-center text-xl font-semibold whitespace-nowrap dark:text-white"><!--AntCMS-SiteTitle--></span>
<span class="self-center text-xl font-semibold whitespace-nowrap dark:text-white"><!--AntCMS-SiteTitle--></span>
</a>
<button data-collapse-toggle="navbar-solid-bg" type="button" class="inline-flex items-center p-2 ml-3 text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600" aria-controls="navbar-solid-bg" aria-expanded="false">
<button data-collapse-toggle="navbar-solid-bg" type="button"
class="inline-flex items-center p-2 ml-3 text-sm text-gray-500 rounded-lg md:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600"
aria-controls="navbar-solid-bg" aria-expanded="false">
<span class="sr-only">Open main menu</span>
<svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z" clip-rule="evenodd"></path></svg>
<svg class="w-6 h-6" aria-hidden="true" fill="currentColor" viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd"
d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z"
clip-rule="evenodd"></path>
</svg>
</button>
<div class="hidden w-full md:block md:w-auto" id="navbar-solid-bg">
<ul class="flex flex-col mt-4 rounded-lg bg-gray-50 md:flex-row md:space-x-8 md:mt-0 md:text-sm md:font-medium md:border-0 md:bg-transparent dark:bg-zinc-800 md:dark:bg-transparent dark:border-gray-700">
<ul
class="flex flex-col mt-4 rounded-lg bg-gray-50 md:flex-row md:space-x-8 md:mt-0 md:text-sm md:font-medium md:border-0 md:bg-transparent dark:bg-zinc-800 md:dark:bg-transparent dark:border-gray-700">
<!--AntCMS-Navigation-->
</ul>
</div>
@ -40,11 +48,12 @@
<div class="w-1/12 px-4"></div>
</div>
</div>
<footer class="text-center text-lg-start">
<div class="text-center p-3 bg-gray-100 dark:bg-zinc-900">
Powered by
<a href="https://github.com/BelleNottelling/AntCMS/" class="text-blue-500 dark:text-blue-400 hover:text-blue-400 dark:hover:text-blue-500">AntCMS</a>
<a href="https://github.com/BelleNottelling/AntCMS/"
class="text-blue-500 dark:text-blue-400 hover:text-blue-400 dark:hover:text-blue-500">AntCMS</a>
<!--AntCMS-Debug-->
</div>
</footer>

View file

@ -49,9 +49,22 @@ if ($currentConfg['forceHTTPS'] && 'cli' !== PHP_SAPI) {
}
$requestedPage = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$segments = explode('/', $requestedPage);
if ($segments[0] === '') {
array_shift($segments);
}
if ($segments[0] === 'Themes' && $segments[2] === 'Assets') {
$antCms->serveContent(AntDir . $requestedPage);
exit;
}
$indexes = ['/', '/index.php', '/index.html'];
if (in_array($requestedPage, $indexes)) {
if (in_array($segments[0], $indexes)) {
$antCms->renderPage('/');
exit;
} else {
$antCms->renderPage($requestedPage);
exit;
}