Steffen
Well-known member
Unless you change the setting "Create pages for categories" from disabled to enabled, the 301 redirects for categories don't work. I'm in a little hurry and this is the workaround I've come up with so far:
(I don't understand why the second part of the diff is necessary. There must be a better way.)
Diff:
diff --git a/src/addons/XF301VB/Pub/Controller/Redirect.php b/src/addons/XF301VB/Pub/Controller/Redirect.php
index f1d264ccd..21e610e04 100644
--- a/src/addons/XF301VB/Pub/Controller/Redirect.php
+++ b/src/addons/XF301VB/Pub/Controller/Redirect.php
@@ -146,6 +146,11 @@ class Redirect extends Controller
return $this->noPermission();
}
+ if ($content instanceof \XF\Entity\Node && $content->node_type_id === 'Category')
+ {
+ $route = 'categories';
+ }
+
$extraParams = [];
if ($params instanceof ParameterBag)
@@ -156,7 +161,7 @@ class Redirect extends Controller
}
}
- return $this->redirectPermanently($this->buildLink($route, $content, $extraParams));
+ return $this->redirectPermanently(str_replace('/.#', '/#', $this->buildLink($route, $content, $extraParams)));
}
}
(I don't understand why the second part of the diff is necessary. There must be a better way.)