-
Notifications
You must be signed in to change notification settings - Fork 1
/
class.tx_forcerealurls.php
48 lines (36 loc) · 1.43 KB
/
class.tx_forcerealurls.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
class tx_forcerealurls {
function check($params,$pObj) {
if ($pObj->siteScript && $pObj->config['config']['tx_realurl_enable'] && (
substr($pObj->siteScript, 0, 9) == 'index.php' ||
substr($pObj->siteScript, 0, 1) == '?'
)) {
$extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['forcerealurls']);
// Skipping section
if ($extConf['skip_if_logged_in'] && $GLOBALS['BE_USER']->user) {
return;
}
$query = array();
parse_str(t3lib_div::getIndpEnv('QUERY_STRING'), $query);
if ($extConf['skip_if_no_cache'] && $query['no_cache']) {
return;
}
if ($extConf['skip_if_typeNum'] && $query['type']) {
return;
}
// Stripping section
$strip_params = explode(' ', $extConf['strip_params']);
foreach($strip_params as $strip_param) {
unset ($query[$strip_param]);
}
$queryString = http_build_query($query);
$baseURL = $pObj->config['config']['baseURL'];
$LD = $pObj->tmpl->linkData($pObj->page,'',false,'','',$queryString);
$url = $baseURL.$LD['totalURL'];
header('HTTP/1.1 301 Moved Permanently');
header('Location: '.$url);
header('X-Redirected-By: forcerealurls');
exit;
}
}
}