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 $physical_template
+ * @return string
+ * @access public
+ */
+ public function getSeoTemplate($physical_template)
+ {
+ return $this->UrlManager->getSeoTemplate($physical_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 $physical_template
+ * @return string
+ * @access public
+ */
+ public function getSeoTemplate($physical_template)
+ {
+ $mapping_key = $physical_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,22 @@
$this->Application->VerifyThemeId();
$this->Application->VerifyLanguageId();
}
+
+ $physical_template = $this->Application->GetVar('t');
+
+ if ( !$this->Application->ConfigValue('ForceCanonicalUrls') ) {
+
+ return;
+ }
+
+ $seo_template = $this->Application->getSeoTemplate($physical_template);
+
+ if ( $seo_template && $seo_template != $physical_template ) {
+ trigger_error('Request url "' . $_SERVER['REQUEST_URI'] . '" points directly to physical template', E_USER_NOTICE);
+ $url_params = $this->getRedirectParams();
+ $url_params['response_code'] = 301;
+ $this->Application->Redirect($seo_template, $url_params);
+ }
}
/**