-
Notifications
You must be signed in to change notification settings - Fork 9
Redirects
Joomlatools Pages supports two methods of redirecting. "External" (ie. permanent) redirects, and "Internal" (ie. temporary) redirects. Both have their specific uses.
Redirects can be defined either in the page frontmatter or in the configuration. Through the configuration, it's possible to create routed redirects that will match multiple URLs.
Redirects can be defined in your configuration or in the page frontmatter.
To redirect a specific page you can set the redirect
property to the internal path or the external URL to redirect the page too.
----
redirect: path/to/page
---
In the configuration redirects can be configured using the redirects
setting and uses the format: array('/path' => '/target')
. The target can be both an internal path, or an external URL.
'redirects' => [
'/path/to/foo' => '/path/to/other/foo' //internal
'/path/to/bar' => 'https://example.com/path/to/bar' //external
]
See also: Configuration > Routing Options
A path and/or target can be dynamic in which case named path arguments will be replaced in the target (if they exist).
Example:
'redirects' => [
'/oldblog/[digit:year]' => '/newblog/[:year]' //internal
]
'redirects' => [
'/oldblog/[digit:year]' => 'https://example.com/newblog/[:year]' //external
]
See also: URLs and Linking > Routes > Configuring Routes
An internal redirect is a dummy, easy to remember URL that sends a "temporarily gone" 307 signal to the search engines, which in effect tells them "This URL has moved for now, but keep it around and keep crawling it because it will likely be coming back pretty soon".
Example:
----
redirect: path/to/page
---
A perfect use case would be to create an example.com/promo URL that redirects you to example.com/blog/2016/09-this-months-promo
. You can change this redirect to any URL, any time, and never have to update your marketing material, advertising buy, and so on.
Internal routes are temporary 307s and should not be used as permanent redirects, to generate a permanent redirect always use a fully qualified URL.
An external redirect is a permanent 301 redirect from one URL to another. It sends the page visitors and search engines to a different URL than the one they originally typed into their browser or selected from a search engine results page.
These redirects also link various URLs under one umbrella so search engines rank all of the addresses based on the domain authority from inbound links.
----
redirect: http://example.com/path/to/page
---
- To rebrand or rename a website with a different URL
- To direct traffic to a website from other URLs owned by the same organisation
Browsers cache 301 redirects aggressively, so use these accordingly. Ideally, 301 redirects should be handled via rules in a .htaccess file or nginx conf rule. Server level redirects are faster because the requests don’t have to run Pages to find where to send the request to. ``
Got a question or need help? We have a forum on Github Discussions where you can get in touch with us.