diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php
index 0df4c97594d..15fed80ebf7 100644
--- a/htdocs/websites/index.php
+++ b/htdocs/websites/index.php
@@ -520,7 +520,7 @@ if ($action == 'updatemeta')
$aliascontent = 'id.'.tpl.php\';';
+ $aliascontent.= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; ';
$aliascontent.= 'else require $dolibarr_main_data_root.\'/websites/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
$aliascontent.= '?>'."\n";
$result = file_put_contents($filealias, $aliascontent);
@@ -545,7 +545,7 @@ if ($action == 'updatemeta')
$tplcontent.= "ob_start();\n";
$tplcontent.= "// END PHP ?>\n";
$tplcontent.= ''."\n";
- $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
$tplcontent.= ''.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').''."\n";
$tplcontent.= ''."\n";
$tplcontent.= ''."\n";
@@ -560,7 +560,7 @@ if ($action == 'updatemeta')
$tplcontent.= ''."\n";
$tplcontent.= ''."\n";
$tplcontent.= 'ref.'/htmlheader.html"); ?>'."\n";
- $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
$tplcontent.= ''."\n";
$tplcontent.= '
'."\n";
@@ -674,7 +674,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf
$objectpage->content = GETPOST('PAGE_CONTENT');
// Clean data. We remove all the head section.
- $objectpage->content = preg_replace('//s', '', $objectpage->content);
+ $objectpage->content = preg_replace('/.*<\/head>/s', '', $objectpage->content);
/* $objectpage->content = preg_replace('//s', '', $objectpage->content); */
$res = $objectpage->update($user);
@@ -743,7 +743,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf
$tplcontent.= "ob_start();\n";
$tplcontent.= "// END PHP ?>\n";
$tplcontent.= ''."\n";
- $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
$tplcontent.= ''.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').''."\n";
$tplcontent.= ''."\n";
$tplcontent.= ''."\n";
@@ -757,7 +757,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf
$tplcontent.= ''."\n";
$tplcontent.= ''."\n";
$tplcontent.= 'ref.'/htmlheader.html"); ?>'."\n";
- $tplcontent.= ''."\n";
+ $tplcontent.= ''."\n";
$tplcontent.= ''."\n";
$tplcontent.= ''."\n";