redirect pages with trailing slash
This commit is contained in:
parent
186ee576e7
commit
9676e995ef
@ -241,7 +241,7 @@ EOF;
|
||||
if (isset($args['id'])) {
|
||||
$id = $args['id'];
|
||||
}
|
||||
$disabled = isset($args['disabled'])?'disabled':'';
|
||||
$disabled = empty($args['disabled'])?'':'disabled';
|
||||
|
||||
$class = 'form-control';
|
||||
if (isset($args['class'])) {
|
||||
|
@ -208,8 +208,6 @@
|
||||
'tip'=>$L->g('Write a template name to filter the page in the theme and change the style of the page.')
|
||||
));
|
||||
|
||||
echo Bootstrap::formTitle(array('title'=>'SEO'));
|
||||
|
||||
// Tags
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'tags',
|
||||
@ -219,6 +217,8 @@
|
||||
'tip'=>$L->g('Write the tags separated by comma')
|
||||
));
|
||||
|
||||
echo Bootstrap::formTitle(array('title'=>'SEO'));
|
||||
|
||||
// Friendly URL
|
||||
echo Bootstrap::formInputText(array(
|
||||
'name'=>'slug',
|
||||
|
@ -212,7 +212,7 @@ echo Bootstrap::pageTitle(array('title'=>$L->g('Settings'), 'icon'=>'cog'));
|
||||
'class'=>'',
|
||||
'placeholder'=>'',
|
||||
'tip'=>DOMAIN.$site->uriFilters('blog'),
|
||||
'disabled'=>!$site->uriFilters('blog')
|
||||
'disabled'=>Text::isEmpty($site->uriFilters('blog'))
|
||||
));
|
||||
|
||||
echo '
|
||||
|
@ -58,6 +58,13 @@ if ($site->homepage() && $url->whereAmI()==='home') {
|
||||
|
||||
// Build specific page
|
||||
if ($url->whereAmI()==='page') {
|
||||
// Check if the URL has trailing slash
|
||||
$pageKey = $url->slug();
|
||||
if (Text::endsWith($pageKey, '/')) {
|
||||
$pageKey = rtrim($pageKey, '/');
|
||||
Redirect::url(DOMAIN_PAGES.$pageKey);
|
||||
}
|
||||
|
||||
$content[0] = $page = buildThePage();
|
||||
}
|
||||
// Build content by tag
|
||||
|
@ -2,14 +2,14 @@
|
||||
|
||||
class Redirect {
|
||||
|
||||
public static function url($url)
|
||||
public static function url($url, $httpCode=301)
|
||||
{
|
||||
if(!headers_sent()) {
|
||||
header("Location:".$url, TRUE, 302);
|
||||
if (!headers_sent()) {
|
||||
header("Location:".$url, TRUE, $httpCode);
|
||||
exit;
|
||||
}
|
||||
|
||||
exit('<meta http-equiv="refresh" content="0; url='.$url.'"/>');
|
||||
exit ('<meta http-equiv="refresh" content="0; url='.$url.'"/>');
|
||||
}
|
||||
|
||||
public static function page($page)
|
||||
|
@ -96,9 +96,8 @@ class Text {
|
||||
|
||||
public static function endsWith($string, $endsString)
|
||||
{
|
||||
$length = (-1)*self::length($endsString);
|
||||
|
||||
return( mb_substr($string, $length)===$endsString );
|
||||
//$length = (-1)*self::length($endsString);
|
||||
return (mb_substr($string, -1)===$endsString);
|
||||
}
|
||||
|
||||
public static function endsWithNumeric($string)
|
||||
|
@ -647,6 +647,7 @@ class Pages extends dbJSON {
|
||||
public function generateKey($text, $parent=false, $returnSlug=false, $oldKey='')
|
||||
{
|
||||
global $L;
|
||||
global $site;
|
||||
|
||||
if (Text::isEmpty($text)) {
|
||||
$text = $L->g('empty');
|
||||
|
@ -306,6 +306,7 @@ function install($adminPassword, $timezone)
|
||||
$dataHead = "<?php defined('BLUDIT') or die('Bludit CMS.'); ?>".PHP_EOL;
|
||||
|
||||
$data = array();
|
||||
$slugs = array();
|
||||
foreach ($pagesToInstall as $page) {
|
||||
|
||||
$slug = $page;
|
||||
@ -324,7 +325,7 @@ function install($adminPassword, $timezone)
|
||||
'position'=>1,
|
||||
'coverImage'=>'',
|
||||
'md5file'=>'',
|
||||
'category'=>'',
|
||||
'category'=>'general',
|
||||
'uuid'=>md5(uniqid()),
|
||||
'parent'=>'',
|
||||
'template'=>'',
|
||||
@ -333,6 +334,8 @@ function install($adminPassword, $timezone)
|
||||
'noarchive'=>false
|
||||
);
|
||||
|
||||
array_push($slugs, $slug);
|
||||
|
||||
file_put_contents(PATH_PAGES.$L->get($slug).DS.FILENAME, $L->get($content), LOCK_EX);
|
||||
}
|
||||
file_put_contents(PATH_DATABASES.'pages.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
||||
@ -438,7 +441,7 @@ function install($adminPassword, $timezone)
|
||||
|
||||
// File categories.php
|
||||
$data = array(
|
||||
'general'=>array('name'=>'General', 'description'=>'', 'template'=>'', 'list'=>array()),
|
||||
'general'=>array('name'=>'General', 'description'=>'', 'template'=>'', 'list'=>$slugs),
|
||||
'music'=>array('name'=>'Music', 'description'=>'', 'template'=>'', 'list'=>array()),
|
||||
'videos'=>array('name'=>'Videos', 'description'=>'', 'template'=>'', 'list'=>array())
|
||||
);
|
||||
|
@ -11,9 +11,6 @@ Things to do:
|
||||
-- time for check user logged
|
||||
-- thumbnails sizes and compression
|
||||
|
||||
- Plugin Links
|
||||
-- Update CSS for Bootstrap
|
||||
|
||||
- Plugin sitemap
|
||||
-- Update CSS for Bootstrap
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user