This is an advanced resource, if you need any help with it, please contact us.
Contents
- How Do WordPress URLs Work?
- Setting Up A Basic Redirect Link
- Redirects for Changed URLs
- Redirecting Changed Categories, Venues, and other “Taxonomies”
1. How Do WordPress URLs Work?
To explain how WordPress URLs work, we’ll look at a few examples:
https://<yourdomain>/
This is called your website’s index or home page URL. It only contains your domain name and nothing after the “/” at the end. WordPress will always resolve this to your Home page, which we configure for you.
https://<yourdomain>/final-slug
This an example a link to a page on your site – the last name in the URL is final-slug. In WordPress the last name is almost always controlled by the post, page, or item you’re viewing. So, if you go and edit that item, you’ll see that the URL / “slug” matches the last name you see in the URL.
https://<yourdomain>/abc/def/final-slug
This is a hierarchical URL, each part separated by a “/” after <yourdomain> is an item in the hierarchy, these are less common in WordPress, but can occur in a few cases:
- Your site has custom post types like products, event calendars, or business listings. These almost always result in a prefix to denote what type of post it is, for example:
- https://<yourdomain>/product/red-t-shirt
- https://<yourdomain>/event/upcoming-event
- https://<yourdomain>/business/new-local-business
- Your site has hierarchical posts, where a post is configured with a parent item – for example:
- https://<yourdomain>/locations – This is a regular page, that might list out all of your business locations.
- https://<yourdomain>/locations/galax-va – This is a regular page, whose parent is set to be the Locations page, and tells visitors about your Galax, VA location.
- In this situation, the hierarchy can contain any text and go multiple levels deep. So, these are all valid URLs, assuming pages exist for them:
- https://<yourdomain>/my-new-page/a-sub-page/another-sub-page
- https://<yourdomain>/another-page/another-sub-page/more-information
- https://<yourdomain>/page-1/page-2
- We often do this on sites with a lot of pages to help group related information, which makes browsing and understanding the site easier for visitors and search engines.
- Your site has taxonomies or categories, these are similar to the custom post types.
2. Setting Up A Basic Redirect Link
What if you want to setup a URL and have it go to another page or file on your website? For example, having a short link like https://<yourdomain>/menu go to https://<yourdomain>/food-menu ?
You can set this up going to Tools -> Redirection in the backend and clicking Add New. Then you can enter in the following parameters:
- Source URL: The URL you want to redirect, in our example it would be /menu
- Destination URL: Where you want the URL to go, in our example it would be https://<yourdomain>/food-menu
Notice that for Destination URL we included the https://<yourdomain>/ part. This is because the destination URL can be anywhere on your site, or even another website on the Internet. So we have to include that part. Meanwhile the Source URL can only be a path on https://<yourdomain>/.
3. Redirects For Changed URLs
If you want to change the URL for an item on your site, but not break existing links out there for it, you can setup your site to track changed URLs.
For example maybe you have a page like https://<yourdomain>/my-event-2023 and want to change it to https://<yourdomain>/my-event-2024 but make sure folks who still have the old link can reach the new URL.
You can configure WordPress to track the changes you make to URLs so that when you change https://<yourdomain>/my-event-2023 to https://<yourdomain>/my-event-2024, it will automatically add a redirect for https://<yourdomain>/my-event-2023 to https://<yourdomain>/my-event-2024.
To configure this go to Tools -> Redirection then Options and URL Monitor.
Redirect Loops: “Too Many Redirects” Error
Configuring the above option can lead to redirect loops. For example, where https://<yourdomain/abc refers to https://<yourdomain/def and https://<yourdomain/def refers to https://<yourdomain/abc. In this example a visitor will be sent from /abc to /def, and from /def to /abc forever, and the page will never load.
This can happen if for example you change a URL to /my-event, then change it to /my-event-2024, then change it back to /my-event-2024.
You can fix this by going to Tools -> Redirection and removing the offending redirect.
4. Redirecting Changed Categories, Venues, and other “Taxonomies”
If you change a category URL, like say change your product category /jewelry to /handmade-jewelry you’ll need to manually setup a redirect from /jewelry to /handmade-jewerly in Tools -> Redirection.