fix: 🐛 fix handling of URLS (now uses config file prefix)
This commit is contained in:
parent
c60b052951
commit
0f2634749d
2 changed files with 17 additions and 5 deletions
|
@ -17,6 +17,10 @@ RewriteRule ^/?raw/(.*)$ raw/%{HTTP_HOST}/$1 [L,END]
|
|||
# RewriteCond %{HTTPS} !on
|
||||
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L,END]
|
||||
|
||||
RewriteCond %{REQUEST_URI} !^/api/
|
||||
RewriteCond %{REQUEST_URI} /\w+$
|
||||
RewriteRule (.*) $1/ [R=301,L,END]
|
||||
|
||||
RewriteCond %{REQUEST_URI} !^/?(src/dbtest\.php|static|raw|robots\.txt).*
|
||||
RewriteRule (.*) src/router.php
|
||||
|
||||
|
@ -30,4 +34,4 @@ Options +Indexes
|
|||
|
||||
<filesMatch ".(js)$">
|
||||
Header set Cache-Control "max-age=60, public"
|
||||
</filesMatch>
|
||||
</filesMatch>
|
||||
|
|
|
@ -96,9 +96,6 @@ class Post implements ArrayAccess {
|
|||
$data['basename'] ??= 'root';
|
||||
}
|
||||
|
||||
$post_data['host'] ??= 'localhost:8081';
|
||||
|
||||
$data['url'] ??= 'http://' . $post_data['host'] . $post_data['path'];
|
||||
|
||||
$data['basename'] ??= basename($data['path']);
|
||||
$data['title'] ??= basename($data['path']);
|
||||
|
@ -107,6 +104,17 @@ class Post implements ArrayAccess {
|
|||
|
||||
$data['type'] ??= self::deduce_type($post_data['path']);
|
||||
|
||||
if(!isset($data['url'])) {
|
||||
$url = $site_defaults['uri_prefix'] . $post_data['path'];
|
||||
// Adding a trailing slash for "non-filename" paths that
|
||||
// need a trail to render properly
|
||||
|
||||
if(!preg_match('/\.\w+$/', $url)) {
|
||||
$url .= '/';
|
||||
}
|
||||
$data['url'] = $url;
|
||||
}
|
||||
|
||||
$data['icon'] ??= self::deduce_icon($data['type']);
|
||||
$data['template'] ??= self::deduce_template($data['type']);
|
||||
|
||||
|
@ -234,4 +242,4 @@ class Post implements ArrayAccess {
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue