Als je een pagina op je Durable-site hebt verwijderd of hernoemd, is het belangrijk om een 301-omleiding in te stellen.Dit helpt bezoekers naar een werkende pagina te leiden in plaats van op een 404-fout te belanden, en zorgt ervoor dat zoekmachines hun index bijwerken met de nieuwe URL.
Volg de onderstaande stappen om een 301-omleiding op uw site te maken:
Ga naar Website > Instellingen.
Scroll naar beneden naar de sectie Aangepaste Code en plak de toepasselijke codes in de kopsectie.
Codes:
Enkele pagina<script>
var currentPath = window.location.pathname;
var pathToRedirect = "/page1";
if (currentPath.includes(pathToRedirect)) {
window.location.href = "/";
}
</script>Meerdere pagina's
<script>
const currentPath = window.location.pathname;
const oldPaths = ["/old-path1", "/old-path2", "/old-path3"];
if (oldPaths.some(path => currentPath.includes(path))) {
// Redirect to the homepage
window.location.href = "/";
}
</script>Meerdere verzendingen naar verschillende pagina's
<script>
const currentPath = window.location.pathname;
const redirects = [
{ oldPath: '/old-path1', newPath: '/' },
{ oldPath: '/old-path2', newPath: '/services' },
{ oldPath: '/old-path3', newPath: '/' }
];
redirects.forEach(({oldPath, newPath}) => {
if(currentPath.includes(oldPath)) {
window.location.href = newPath;
}
});
</script>Klik op Opslaan.
Als je hulp nodig hebt bij het beheren van je redirects of vragen hebt over het opzetten van je site, staat ons team klaar om te helpen.Neem op elk moment contact met ons op en we helpen u graag.