Skip to content

Commit

Permalink
Handle redirects with fragment components
Browse files Browse the repository at this point in the history
  • Loading branch information
jmikola committed Oct 24, 2024
1 parent 2a07f01 commit 899d9f0
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions error.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,12 +254,12 @@

// MongoDB converted from set to book
'set.mongodb' => 'book.mongodb',
'mongodb.installation.homebrew' => 'mongodb.installation',
'mongodb.installation.manual' => 'mongodb.installation',
'mongodb.installation.pecl' => 'mongodb.installation',
'mongodb.installation.windows' => 'mongodb.installation',
'mongodb.persistence.deserialization' => 'mongodb.persistence',
'mongodb.persistence.serialization' => 'mongodb.persistence',
'mongodb.installation.homebrew' => 'mongodb.installation#mongodb.installation.homebrew',
'mongodb.installation.manual' => 'mongodb.installation#mongodb.installation.manual',
'mongodb.installation.pecl' => 'mongodb.installation#mongodb.installation.pecl',
'mongodb.installation.windows' => 'mongodb.installation#mongodb.installation.windows',
'mongodb.persistence.deserialization' => 'mongodb.persistence#mongodb.persistence.deserialization',
'mongodb.persistence.serialization' => 'mongodb.persistence#mongodb.persistence.serialization',
];

if (isset($manual_page_moves[$URI])) {
Expand All @@ -268,7 +268,13 @@
} elseif (preg_match("!^manual/([^/]+)/([^/]+).php$!", $URI, $match) &&
isset($manual_page_moves[$match[2]])) {
status_header(301);
mirror_redirect("/manual/$match[1]/" . $manual_page_moves[$match[2]] . ".php");

$parts = explode('#', $manual_page_moves[$match[2]], 2);
if (count($parts) === 1) {
mirror_redirect("/manual/{$match[1]}/{$parts[0]}.php");
} else {
mirror_redirect("/manual/{$match[1]}/{$parts[0]}.php#{$parts[1]}");
}
}

$manual_redirections = [
Expand Down

0 comments on commit 899d9f0

Please sign in to comment.