Skip to content

Node.js based forum software built for the modern web

closes #1126

barisusakli611c16b5a62d
diff --git a/src/controllers/categories.js b/src/controllers/categories.js
index 9d0a1aae49..4dd9d0e8a5 100644
--- a/src/controllers/categories.js
+++ b/src/controllers/categories.js
@@ -65,6 +65,16 @@ categoriesController.get = function(req, res, next) {
page = req.query.page || 1,
uid = req.user ? req.user.uid : 0;
+ if (!req.params.slug && !res.locals.isAPI) {
+ categories.getCategoryField(cid, 'slug', function(err, slug) {
+ if (err) {
+ return next(err);
+ }
+ res.redirect('/category/' + slug);
+ });
+ return;
+ }
+
async.waterfall([
function(next) {
categoryTools.privileges(cid, uid, function(err, categoryPrivileges) {
diff --git a/src/controllers/topics.js b/src/controllers/topics.js
index 15452aaf80..50d3fefa37 100644
--- a/src/controllers/topics.js
+++ b/src/controllers/topics.js
@@ -18,6 +18,16 @@ topicsController.get = function(req, res, next) {
uid = req.user ? req.user.uid : 0,
privileges;
+ if (!req.params.slug && !res.locals.isAPI) {
+ topics.getTopicField(tid, 'slug', function(err, slug) {
+ if (err) {
+ return next(err);
+ }
+ res.redirect('/topic/' + slug);
+ });
+ return;
+ }
+
async.waterfall([
function(next) {
threadTools.privileges(tid, ((req.user) ? req.user.uid || 0 : 0), function(err, userPrivileges) {