Hoppa till innehållet
Dotweb
Logga in

Kategorier

Den här artikeln finns inte på svenska än. Här är den engelska versionen.

Creating 301 redirects

Permanently send visitors from an old page URL to a new one so no one lands on a broken page.

If you need to route incoming traffic permanently from one page to another, 301 redirects are the best solution. URL redirection (or URL forwarding) is a technique for making a webpage available under more than one address.

You may want to change a page path (URL) for many reasons, including:

  • You want to reorganize your website’s structure.
  • You want to migrate your existing site to the Website Builder.
  • You need to delete a page.
  • You want to change an existing page’s publish path.
  • You have found a broken URL.

When you replace an old URL with a new one, the old URL may still show up in the search results, and people visiting it will see a 404 page, which hurts your SEO. But when you set up a 301 redirect, visitors clicking the old URL are taken to a specified new page and will not get lost.

Redirecting a page

To permanently redirect your old page to a new URL on your site, follow these steps:

  1. Click the Menu icon in the upper left corner of the editor. Choose the Settings tab to open Website settings.

    The editor Menu open with the Settings tab for Website settings

  2. Choose the Hosting tab in Website settings.

    The Hosting tab selected in Website settings

  3. Click the Create redirect button.

  4. In the pop up window, add the Old path (for example /original-url) and the New path (for example /entirely-new-url), then click Submit.

    The Create redirect pop up with Old path and New path fields

  5. Publish your site and test the redirect by entering the old URL in a new browser tab. There can be up to a one minute delay after publishing before the redirect applies.

Clear your cache to see changes

Browsers usually cache 301 redirects. So if you applied a redirect from URL A to URL B, tested it in your browser, and then redirected URL A to URL C, you need to clear your cache to see the change. Alternatively, you can use Incognito mode (öppnas i en ny flik).

Editing and deleting a redirect

All your redirects form a sortable list that you can reorder by dragging and dropping the items. The redirect at the top of the list is given the highest priority. They apply one by one from top to bottom.

When you hover over a redirect, two icons appear on the right side of the item. Click the Settings icon to change your redirect, and the Trash bin icon to delete it.

A redirect list item showing the Settings and Trash bin icons on hover

Redirecting a folder

You can create a group redirect (a wildcard redirect) that redirects related URLs sharing the same path. To redirect all pages of a directory (a folder) to a new destination, follow these steps:

  1. Add a capture group (.*) in the old URL structure in the Old path field (for example /old-folder/(.*)).
  2. Add the target URL /$1 for the new URL structure in the New path field (for example /entirely/new-folder/$1).

Multiple capture groups

You can add multiple capture groups to create more complex redirect rules. For example, /blogs/(.*)/(.*) can be redirected to /articles/$1/$2.

Wildcard redirect examples

Suppose you are reorganizing your website’s structure and want to redirect some pages. For example, you have a restaurant folder with food and drinks subfolders, and you want to redirect all the subfolders and their pages from the restaurant folder to menu. If you redirect it page by page, the sequence looks like this:

domain.com/restaurant/food/breakfast/    to    domain.com/menu/food/breakfast/
domain.com/restaurant/food/lunch/        to    domain.com/menu/food/lunch/
domain.com/restaurant/drinks/coffee/     to    domain.com/menu/drinks/coffee/

If you present your categories as capture groups marked with (.*), you can achieve this with a single redirect:

  • Old path: /restaurant/(.*)/(.*)/
  • New path: /menu/$1/$2/

Escape characters

Some interfaces do not accept question marks (?) or equal signs (=) in URLs during redirects. Users have to put a $ sign before them to escape these special characters.

The Website Builder handles these special characters perfectly, so you do not need to use any escape characters in your redirect URLs.

Redirect loop

A redirect loop happens when you redirect a URL to another URL that redirects back to the originally requested URL. This creates an infinite cycle of redirects that makes your website visitors and search engines get stuck on your site.

For example, you set up a 301 redirect from URL A to URL B. Then you add a 301 redirect from URL B to URL C, and then URL C redirects back to URL A.

This leads to an endless chain of redirects, producing the following error message in your browser: ERR_TOO_MANY_REDIRECTS.

A browser showing the ERR_TOO_MANY_REDIRECTS error message

You can also create an infinite loop using a capture group (.*) if you set up a redirect like this:

  • Old path: /(.*)/
  • New path: /$1-test/

Domänsökning

Priserna är exklusive moms, som läggs till i kassan.

Välj vad Dotweb får spara i din webbläsare. Du kan ändra ditt val när som helst under Cookieinställningar längst ner på varje sida. Läs mer i vår integritetspolicy.

Alltid på
NamnSyfteLagringstidLeverantör
currencyCookieKommer ihåg vilken valuta priserna visas i.Sessionen, eller 1 år när du har valt enDotweb
localeCookieKommer ihåg språket du har valt.1 årDotweb
consentCookieSparar det här valet.6 månaderDotweb
upm-brand-config:*Lokal lagringMellanlagrar domänsökningens inställningar.Tills den rensasVår faktureringspartner
upm_guest_sessionCookieSätts av vår kassa och håller kvar din varukorg och din session i kassan.Upp till 1 dagVår faktureringspartner
NamnSyfteLagringstidLeverantör
ph_*Cookie, lokal lagring och sessionslagringEtt anonymt ID och en session, så att vi kan se vilka sidor och funktioner som används.Upp till 1 årVår analyspartner (EU)