Skip to content

Commit

Permalink
404 with redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
irfankhan10 committed Feb 17, 2025
1 parent 01c53b6 commit eef6fea
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 54 deletions.
12 changes: 11 additions & 1 deletion base_site/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ <h1>404 - Page Not Found</h1>
<script>
// Get the current URL path
const path = window.location.pathname;


// Check if the URL starts with /subpath/
if (path.startsWith('/h-series/')) {
const regex = new RegExp(`${'h-series'}(/.*)`);
const match = path.match(regex);
const pathAfterPhrase = match ? match[1] : "";
console.log(pathAfterPhrase);
// Redirect to a custom 404 page for /subpath/
window.location.href = '/h-series/404.html';
window.location.href = '/systems/' + pathAfterPhrase;
}
else {
setTimeout(() => {
window.location.href = "/";
}, 3000);
}
</script>
</body>
Expand Down
12 changes: 11 additions & 1 deletion base_site/404/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,21 @@ <h1>404 - Page Not Found</h1>
<script>
// Get the current URL path
const path = window.location.pathname;


// Check if the URL starts with /subpath/
if (path.startsWith('/h-series/')) {
const regex = new RegExp(`${'h-series'}(/.*)`);
const match = path.match(regex);
const pathAfterPhrase = match ? match[1] : "";
console.log(pathAfterPhrase);
// Redirect to a custom 404 page for /subpath/
window.location.href = '/h-series/404.html';
window.location.href = '/systems/' + pathAfterPhrase;
}
else {
setTimeout(() => {
window.location.href = "/";
}, 3000);
}
</script>
</body>
Expand Down
52 changes: 0 additions & 52 deletions base_site/h-series/404.html

This file was deleted.

0 comments on commit eef6fea

Please sign in to comment.