+2008-10-14 Ernesto Baschny <ernst@cron-it.de>
+
+ * Added feature #9400: enables to have specific HTTP status codes on a sys_domain record when doing a redirect (new field sys_domain.redirectHttpStatusCode)
+
2008-10-14 Dmitry Dulepov <dmitry@typo3.org>
* Fixed bug #9523: class.t3lib_htmlmail.php produces null headers in HTML messages
$domain = ereg_replace('\/*$','',$domain);
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
- 'pages.uid,sys_domain.redirectTo,sys_domain.prepend_params',
+ 'pages.uid,sys_domain.redirectTo,sys_domain.redirectHttpStatusCode,sys_domain.prepend_params',
'pages,sys_domain',
'pages.uid=sys_domain.pid
AND sys_domain.hidden=0
$GLOBALS['TYPO3_DB']->sql_free_result($res);
if ($row) {
if ($row['redirectTo']) {
- $rURL = $row['redirectTo'];
+ $redirectUrl = $row['redirectTo'];
if ($row['prepend_params']) {
- $rURL = ereg_replace('\/$','',$rURL);
+ $redirectUrl = ereg_replace('\/$', '', $redirectUrl);
$prependStr = ereg_replace('^\/','',substr($request_uri,strlen($path)));
- $rURL.= '/'.$prependStr;
+ $redirectUrl .= '/' . $prependStr;
+ }
+
+ $statusCode = intval($row['redirectHttpStatusCode']);
+ if ($statusCode && defined('t3lib_div::HTTP_STATUS_' . $statusCode)) {
+ t3lib_div::redirect($redirectUrl, constant('t3lib_div::HTTP_STATUS_' . $statusCode));
+ } else {
+ t3lib_div::redirect($redirectUrl, 't3lib_div::HTTP_STATUS_301');
}
- Header('HTTP/1.1 301 Moved Permanently');
- Header('Location: '.t3lib_div::locationHeaderUrl($rURL));
exit;
} else {
return $row['uid'];
hidden tinyint(4) unsigned DEFAULT '0' NOT NULL,
domainName varchar(80) DEFAULT '' NOT NULL,
redirectTo varchar(120) DEFAULT '' NOT NULL,
+ redirectHttpStatusCode int(4) unsigned DEFAULT '301' NOT NULL,
sorting int(10) unsigned DEFAULT '0' NOT NULL,
prepend_params int(10) DEFAULT '0' NOT NULL,
<label index="sys_domain">Domain</label>
<label index="sys_domain.domainName">Domain:</label>
<label index="sys_domain.redirectTo">Redirect to:</label>
+ <label index="sys_domain.redirectHttpStatusCode">HTTP Status Code for the Redirect:</label>
+ <label index="sys_domain.redirectHttpStatusCode.301">Moved permanently (301)</label>
+ <label index="sys_domain.redirectHttpStatusCode.302">Found (302)</label>
+ <label index="sys_domain.redirectHttpStatusCode.303">See other (303)</label>
+ <label index="sys_domain.redirectHttpStatusCode.307">Moved temporarily (307)</label>
<label index="sys_domain.prepend_params">Transfer parameters to Redirect URL:</label>
<label index="sys_template">Template</label>
<label index="sys_template.title">Template title:</label>
'softref' => 'substitute'
),
),
+ 'redirectHttpStatusCode' => array(
+ 'exclude' => 1,
+ 'label' => 'LLL:EXT:cms/locallang_tca.xml:sys_domain.redirectHttpStatusCode',
+ 'config' => array(
+ 'type' => 'select',
+ 'items' => array(
+ array('LLL:EXT:cms/locallang_tca.xml:sys_domain.redirectHttpStatusCode.301', '301'),
+ array('LLL:EXT:cms/locallang_tca.xml:sys_domain.redirectHttpStatusCode.302', '302'),
+ array('LLL:EXT:cms/locallang_tca.xml:sys_domain.redirectHttpStatusCode.303', '303'),
+ array('LLL:EXT:cms/locallang_tca.xml:sys_domain.redirectHttpStatusCode.307', '307'),
+ ),
+ 'size' => 1,
+ 'maxitems' => 1,
+ ),
+ ),
'hidden' => array(
'label' => 'LLL:EXT:lang/locallang_general.php:LGL.disable',
'exclude' => 1,
'1' => array('showitem' => 'hidden;;;;1-1-1,domainName;;1;;3-3-3,prepend_params')
),
'palettes' => array(
- '1' => array('showitem' => 'redirectTo')
+ '1' => array('showitem' => 'redirectTo, redirectHttpStatusCode')
)
);