Index: install/english.lang =================================================================== --- install/english.lang (revision 15648) +++ install/english.lang (working copy) @@ -171,6 +171,7 @@ RXhjbHVkZSB0ZW1wbGF0ZSBiYXNlZCBTZWN0aW9ucyBmcm9tIFNlYXJjaCBSZXN1bHRzIChpZS4gVXNlciBSZWdpc3RyYXRpb24p RmlsZW5hbWUgU3BlY2lhbCBDaGFyIFJlcGxhY2VtZW50 Rmlyc3QgRGF5IE9mIFdlZWs= + Rm9yY2UgQ2Fub25pY2FsIFVSTHM= QWx3YXlzIHVzZSBJbWFnZU1hZ2ljayB0byByZXNpemUgaW1hZ2Vz Rm9yY2UgUmVkaXJlY3QgdG8gU2VsZWN0ZWQgVVJMIEVuZGluZw== UmVkaXJlY3QgdG8gSFRUUCB3aGVuIFNTTCBpcyBub3QgcmVxdWlyZWQ= Index: install/install_data.sql =================================================================== --- install/install_data.sql (revision 15648) +++ install/install_data.sql (working copy) @@ -32,6 +32,7 @@ INSERT INTO SystemSettings VALUES(DEFAULT, 'PageHitCounter', '0', 'In-Portal', 'in-portal:configure_advanced', '', '', '', NULL, NULL, 0, 0, 0, NULL); INSERT INTO SystemSettings VALUES(DEFAULT, 'UseModRewrite', '0', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsWebsite', 'la_config_use_modrewrite', 'checkbox', '', '', 10.01, 0, 1, NULL); INSERT INTO SystemSettings VALUES(DEFAULT, 'ModRewriteUrlEnding', '.html', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsWebsite', 'la_config_ModRewriteUrlEnding', 'select', '', '=+||/=+/||.html=+.html', 10.011, 0, 0, NULL); +INSERT INTO SystemSettings VALUES(DEFAULT, 'ForceCanonicalUrls', '0', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsWebsite', 'la_config_ForceCanonicalUrls', 'checkbox', '', '', 10.0125, 0, 0, NULL); INSERT INTO SystemSettings VALUES(DEFAULT, 'ForceModRewriteUrlEnding', '0', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsWebsite', 'la_config_ForceModRewriteUrlEnding', 'checkbox', '', NULL, 10.012, 0, 0, 'hint:la_config_ForceModRewriteUrlEnding'); INSERT INTO SystemSettings VALUES(DEFAULT, 'UseContentLanguageNegotiation', '0', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsWebsite', 'la_config_UseContentLanguageNegotiation', 'checkbox', '', '', 10.013, 0, 0, NULL); INSERT INTO SystemSettings VALUES(DEFAULT, 'cms_DefaultDesign', '#default_design#', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsWebsite', 'la_config_DefaultDesignTemplate', 'text', NULL, NULL, 10.02, 0, 0, NULL); Index: kernel/application.php =================================================================== --- kernel/application.php (revision 15648) +++ kernel/application.php (working copy) @@ -1701,6 +1701,18 @@ } /** + * Returns seo template by physical template + * + * @param string $parsed_template + * @return string + * @access public + */ + public function getSeoTemplate($parsed_template) + { + return $this->UrlManager->getSeoTemplate($parsed_template); + } + + /** * Returns template name, that corresponds with given virtual (not physical) page id * * @param int $page_id Index: kernel/managers/url_manager.php =================================================================== --- kernel/managers/url_manager.php (revision 15648) +++ kernel/managers/url_manager.php (working copy) @@ -379,6 +379,20 @@ } /** + * Returns seo template by physical template + * + * @param string $parsed_template + * @return string + * @access public + */ + public function getSeoTemplate($parsed_template) + { + $mapping_key = $parsed_template . ':' . $this->Application->GetVar('m_theme'); + + return isset($this->structureTemplateMapping[$mapping_key]) ? $this->structureTemplateMapping[$mapping_key] : ''; + } + + /** * Returns template name, that corresponds with given virtual (not physical) page id * * @param int $page_id Index: kernel/utility/http_query.php =================================================================== --- kernel/utility/http_query.php (revision 15648) +++ kernel/utility/http_query.php (working copy) @@ -369,6 +369,20 @@ $this->Application->VerifyThemeId(); $this->Application->VerifyLanguageId(); } + + $parsed_template = $this->Application->GetVar('t'); + + if ( !$this->Application->ConfigValue('ForceCanonicalUrls') || preg_match('|' . BASE_PATH . '/' . $parsed_template . '(.*)|i', $_SERVER['REQUEST_URI'])) { + + return; + } + + $seo_template = $this->Application->getSeoTemplate($parsed_template); + + if ( $seo_template && $seo_template != $parsed_template ) { + trigger_error('Request url "' . $_SERVER['REQUEST_URI'] . '" points directly to physical template', E_USER_NOTICE); + $this->Application->Redirect($parsed_template, Array ('response_code' => 301, 'use_section' => 1)); + } } /**