Commit 64002f21 authored by Matija Obreza's avatar Matija Obreza
Browse files

Redirect /welcome to /

parent f63aff6c
......@@ -25,11 +25,24 @@ app.use((req, res, next) => {
console.log('Incoming request, url:', req.url);
next();
});
// Redirect to `/` if path is `/welcome`
app.get('/welcome', (req, res) => {
const oldPath = req.url;
console.log(`Redirecting ${oldPath} to ${config.frontendPath}/`);
res.redirect(301, `${config.frontendPath}/`);
});
// Redirect to `/` if path is `/{lang}/welcome`
app.get('/*/welcome', (req, res) => {
const oldPath = req.url;
const lang = oldPath.substr(1, 3);
console.log(`Redirecting ${oldPath} to ${config.frontendPath}/${lang}`);
res.redirect(301, `${config.frontendPath}/${lang}`);
});
// Redirect to `/` if path contains `/en`
app.get('/en/*', (req, res) => {
const oldPath = req.url;
const redirectPath = oldPath.substr(3, oldPath.length);
res.redirect(`${config.frontendPath}${redirectPath}`);
res.redirect(301, `${config.frontendPath}${redirectPath}`);
});
// Enable compression
app.use(compression());
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment