diff --git a/class.tx_forcerealurls.php b/class.tx_forcerealurls.php index 0d0e89a..3a03f7a 100644 --- a/class.tx_forcerealurls.php +++ b/class.tx_forcerealurls.php @@ -4,19 +4,45 @@ 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) == '?' - )) { - $baseURL = $pObj->config['config']['baseURL']; - $LD = $pObj->tmpl->linkData($pObj->page,'',$pObj->no_cache,'','',t3lib_div::getIndpEnv('QUERY_STRING')); - $url = $baseURL.$LD['totalURL']; - - header('HTTP/1.1 301 Moved Permanently'); - header('Location: '.$url); - - exit; + 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; } } } -?> \ No newline at end of file diff --git a/ext_conf_template.txt b/ext_conf_template.txt new file mode 100644 index 0000000..b34a96d --- /dev/null +++ b/ext_conf_template.txt @@ -0,0 +1,12 @@ + # cat=basic; type=string; label=Strip params. Strip these parameters if they are present in the query-string (Separate with spaces) +strip_params = no_cache + + # cat=basic; type=boolean; label=Logged in skip. Skip redirect if logged in. Check this if you do not want to redirect users that are logged in into the backend. +skip_if_logged_in = 1 + + # cat=basic; type=boolean; label=No cache skip. Check this if you do not want to get redirects when no_cache is on. This is typically a development setting. This will take precedence over strip_params. +skip_if_no_cache = 0 + + # cat=basic; type=boolean; label=typeNum skip. Check this if you do not want to get redirects for non-0 typeNum. This is often used if you are doing some sort of AJAX specific pages. +skip_if_typeNum = 1 +