Skip to content

Commit

Permalink
Add a forum redirection page
Browse files Browse the repository at this point in the history
This is done in the 404 error page as it will match any invalid URL,
including `/forum/viewtopic.php`. We can't create a page with a custom
permalink set to `/forum/viewtopic.php`, as GitHub Pages doesn't set
the MIME type correctly, which causes the browser to download the page.

This closes #187.
  • Loading branch information
Calinou authored and sfan5 committed Sep 19, 2019
1 parent b48b080 commit db33ce9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
permalink: 404.html
---

<script>
// Forum URL redirection
const urlParams = new URLSearchParams(window.location.search.slice(1));

if (urlParams.has('id')) {
// Convert to a number for security (only numeric values make sense anyway)
const topicId = Number(urlParams.get('id'));
window.location.replace(`https://forum.minetest.net/viewtopic.php?id=${topicId}`);
}
</script>

<section class="section">
<div class="container">
<div class="content">
Expand Down

0 comments on commit db33ce9

Please sign in to comment.