diff --git a/administrator/language/en-GB/plg_system_sef.ini b/administrator/language/en-GB/plg_system_sef.ini
index 60f465d581eb3..213bdca454f8b 100644
--- a/administrator/language/en-GB/plg_system_sef.ini
+++ b/administrator/language/en-GB/plg_system_sef.ini
@@ -5,7 +5,9 @@
PLG_SEF_DOMAIN_DESCRIPTION="If your site can be accessed through more than one domain enter the preferred (sometimes referred to as canonical) domain here.
Note: https://example.com and https://www.example.com are different domains."
PLG_SEF_DOMAIN_LABEL="Site Domain"
+; Deprecated, will be removed in 7.0
PLG_SEF_ENFORCESUFFIX_DESCRIPTION="When enabled and \"Add Suffix to URL\" is also enabled, URLs without suffix will be redirected to the correct one. From version 6.0 onwards this will be the standard behavior and not an option anymore."
+; Deprecated, will be removed in 7.0
PLG_SEF_ENFORCESUFFIX_LABEL="Enforce a suffix by redirect"
PLG_SEF_INDEXPHP_DESCRIPTION="This option enables a stricter handling of 'index.php' in URLs when 'Use URL Rewriting' is enabled in Global Configuration. It will remove 'index.php' if a URL still contains it and redirect incoming requests with 'index.php' to the version without the 'index.php'."
PLG_SEF_INDEXPHP_LABEL="Strict handling of index.php"
diff --git a/installation/sql/mysql/base.sql b/installation/sql/mysql/base.sql
index d22424abc45c5..be506e3463caa 100644
--- a/installation/sql/mysql/base.sql
+++ b/installation/sql/mysql/base.sql
@@ -365,7 +365,7 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`,
(0, 'plg_system_remember', 'plugin', 'remember', 'system', 0, 1, 1, 0, 1, '', '', '', 16, 0),
(0, 'plg_system_schedulerunner', 'plugin', 'schedulerunner', 'system', 0, 1, 1, 0, 1, '', '{}', '', 17, 0),
(0, 'plg_system_schemaorg', 'plugin', 'schemaorg', 'system', 0, 1, 1, 0, 1, '', '{}', '', 18, 0),
-(0, 'plg_system_sef', 'plugin', 'sef', 'system', 0, 1, 1, 0, 1, '', '{"domain":"","indexphp":"1","trailingslash":"0","enforcesuffix":"1","strictrouting":"1"}', '', 19, 0),
+(0, 'plg_system_sef', 'plugin', 'sef', 'system', 0, 1, 1, 0, 1, '', '{"domain":"","indexphp":"1","trailingslash":"0","strictrouting":"1"}', '', 19, 0),
(0, 'plg_system_shortcut', 'plugin', 'shortcut', 'system', 0, 1, 1, 0, 1, '', '{}', '', 21, 0),
(0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, 1, '', '{}', '', 22, 0),
(0, 'plg_system_stats', 'plugin', 'stats', 'system', 0, 1, 1, 0, 1, '', '', '', 23, 0),
diff --git a/installation/sql/postgresql/base.sql b/installation/sql/postgresql/base.sql
index 69ebeaaf2e789..ea96462b80769 100644
--- a/installation/sql/postgresql/base.sql
+++ b/installation/sql/postgresql/base.sql
@@ -371,7 +371,7 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder",
(0, 'plg_system_remember', 'plugin', 'remember', 'system', 0, 1, 1, 0, 1, '', '', '', 16, 0),
(0, 'plg_system_schedulerunner', 'plugin', 'schedulerunner', 'system', 0, 1, 1, 0, 1, '', '{}', '', 17, 0),
(0, 'plg_system_schemaorg', 'plugin', 'schemaorg', 'system', 0, 1, 1, 0, 1, '', '{}', '', 18, 0),
-(0, 'plg_system_sef', 'plugin', 'sef', 'system', 0, 1, 1, 0, 1, '', '{"domain":"","indexphp":"1","trailingslash":"0","enforcesuffix":"1","strictrouting":"1"}', '', 19, 0),
+(0, 'plg_system_sef', 'plugin', 'sef', 'system', 0, 1, 1, 0, 1, '', '{"domain":"","indexphp":"1","trailingslash":"0","strictrouting":"1"}', '', 19, 0),
(0, 'plg_system_shortcut', 'plugin', 'shortcut', 'system', 0, 1, 1, 0, 1, '', '{}', '', 21, 0),
(0, 'plg_system_skipto', 'plugin', 'skipto', 'system', 0, 1, 1, 0, 1, '', '{}', '', 22, 0),
(0, 'plg_system_stats', 'plugin', 'stats', 'system', 0, 1, 1, 0, 1, '', '', '', 23, 0),
diff --git a/libraries/src/Router/SiteRouter.php b/libraries/src/Router/SiteRouter.php
index ad7cfafef3196..c96d132c3911e 100644
--- a/libraries/src/Router/SiteRouter.php
+++ b/libraries/src/Router/SiteRouter.php
@@ -177,12 +177,31 @@ public function parseFormat(&$router, &$uri)
{
$route = $uri->getPath();
- // Identify format
- if (!(str_ends_with($route, 'index.php') || str_ends_with($route, '/')) && $suffix = pathinfo($route, PATHINFO_EXTENSION)) {
+ if (!(str_ends_with($route, 'index.php') || str_ends_with($route, '/'))) {
+ // We don't want suffixes when the URL ends in index.php or with a /
+ return;
+ }
+
+ $suffix = pathinfo($route, PATHINFO_EXTENSION);
+ $nonSEFSuffix = $uri->getVar('format');
+
+ if ($suffix) {
$uri->setVar('format', $suffix);
$route = str_replace('.' . $suffix, '', $route);
$uri->setPath($route);
}
+
+ if ($nonSEFSuffix) {
+ // There is a URL query parameter named "format"
+ $uri->setVar('format', $nonSEFSuffix);
+ $router->setTainted();
+ }
+
+ if (!$suffix) {
+ // We don't have a suffix, so we default to .html at the end
+ $uri->setPath($route . '.html');
+ $router->setTainted();
+ }
}
/**
diff --git a/plugins/system/sef/sef.xml b/plugins/system/sef/sef.xml
index 1ef51a3667ace..467cac9fe0166 100644
--- a/plugins/system/sef/sef.xml
+++ b/plugins/system/sef/sef.xml
@@ -31,19 +31,6 @@
validate="url"
/>
-
-
-
-
-
enforceTrailingSlash();
}
- // Enforce adding a suffix with a redirect
- if ($app->get('sef') && $app->get('sef_suffix') && $this->params->get('enforcesuffix')) {
- $this->enforceSuffix();
- }
-
// Enforce SEF URLs
if ($this->params->get('strictrouting') && $app->getInput()->getMethod() == 'GET') {
$this->enforceSEF();
@@ -323,57 +317,6 @@ function ($match) use ($base, $protocols) {
$app->setBody($buffer);
}
- /**
- * Enforce the URL suffix with a redirect
- *
- * @return void
- *
- * @since 5.2.0
- */
- public function enforceSuffix()
- {
- $origUri = Uri::getInstance();
- $route = $origUri->getPath();
-
- if (str_ends_with($route, 'index.php') || str_ends_with($route, '/')) {
- // We don't want suffixes when the URL ends in index.php or with a /
- return;
- }
-
- // We don't force a suffix for the language homepage
- $segments = explode('/', $route);
- $last = array_pop($segments);
- $sefs = LanguageHelper::getLanguages('sef');
-
- if ($this->getApplication()->getLanguageFilter() && isset($sefs[$last])) {
- return;
- }
-
- $suffix = pathinfo($route, PATHINFO_EXTENSION);
- $nonSEFSuffix = $origUri->getVar('format');
-
- if ($nonSEFSuffix && $suffix !== $nonSEFSuffix) {
- // There is a URL query parameter named "format", which isn't the same to the suffix
- $pathWithoutSuffix = ($suffix !== '') ? substr($route, 0, -(\strlen($suffix) + 1)) : $route;
-
- $origUri->delVar('format');
- $origUri->setPath($pathWithoutSuffix . '.' . $nonSEFSuffix);
- $this->getApplication()->redirect($origUri->toString(), 301);
- }
-
- if ($suffix && $suffix == $nonSEFSuffix) {
- // There is a URL query parameter named "format", which is identical to the suffix
- $origUri->delVar('format');
- $this->getApplication()->redirect($origUri->toString(), 301);
- }
-
- if (!$suffix) {
- // We don't have a suffix, so we default to .html at the end
- $origUri->setPath($route . '.html');
- $this->getApplication()->redirect($origUri->toString(), 301);
- }
- }
-
/**
* Enforce removal of index.php with a redirect
*