TYPO3 - 如果页面禁用则重定向

TYPO3 - Redirect if page disabled

我用的是TYPO3 6.2.

我正在处理一个非常特殊的页面,该页面尚未为 public 准备好,但我发现 Google 已经找到它并将其编入索引。这是一个真正的问题,因为该页面必须仅在 2018 年夏季可用。

如果我在后端禁用了该页面,那么我仍然可以在该页面上工作,并且该页面不再可供其他人使用,但是 URL 会生成一个 404 Not Found

-> 如何生成 301 redirect 到主页?

localconf.php 或安装工具设置:

#have to be 1
$TYPO3_CONF_VARS['SYS']['curlUse'] = 1;

#have to be empty
$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT']['init']['postVarSet_failureMode'] = '';

#logical part
$TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = '/404.html';
$TYPO3_CONF_VARS['FE']['pageNotFound_handling_statheader'] = 'HTTP/1.1 301 Moved Permanently';
$TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = 'USER_FUNCTION:fileadmin/scripts/pagenotfound.php:user_pagenotfound->pagenotfound';

用户函数内容(fileadmin/scripts/pagenotfound.php)

<?php
define('REDIRECTPAGE', '/');
class user_pagenotfound {
function pagenotfound($param, $conf) {
$server_name = $_SERVER;
header("HTTP/1.0 301 Moved Permanently");
print '<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>301 Moved Permanently</title>
<SCRIPT LANGUAGE="JavaScript">
<!--
function doRedirect() {
window.location="http://'.$server_name.REDIRECTPAGE.'";
}
doRedirect();
// -->
</script>
</head>
<body style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;text-align:center;";>
<div style="font-size:20px;text-align:center">The page you have requested cannot be found</div>
<div>If you are not automaticly redirected in 3 seconds please click here: <br />
<br /><a href='.$server_name.'>'.$server_name.'</a></div>
</body>
</html>';
exit;
}
}
?>

来自此处的来源:http://www.typo3forum.net/discussion/34942/301-moved-permanently-statt-404-page-not-found by smartlife 并且:http://blog.marit.ag/2009/03/20/korrektes-404-error-handling-mit-typo3/