URL translation
Every page has a system address such as /content/view/full/58 (see Modules and views). Visitors and search engines should see readable addresses instead, such as /company/about-us. URL translation maps one to the other: each node gets a readable address, a URL alias, made from its name and the names of the nodes above it, and requests for that address are answered by the system view behind it.
Node aliases
- When an object is published, each of its nodes gets an alias per language, built from the parent's alias and the object's name (or the class's URL alias name pattern). Spaces become dashes, letters are lower-cased and characters that do not belong in an address are changed or removed, as set in site.ini [URLTranslator] (WordSeparator=dash, TransformationGroup=urlalias, rules in transform.ini).
- Two siblings with the same name get distinct aliases: the second gets a number, as in about-us2.
- Templates make links from aliases with ezurl: <a href={$node.url_alias|ezurl}>. ezurl adds the siteaccess path and index file where needed.
History: old addresses keep working
When a node is renamed or moved, it gets a new alias, and the old one is kept as a history alias. A request for the old address is redirected to the new one with HTTP 301, so links from other sites and bookmarks keep working and search engines learn the new address. The same holds for every node below a moved or renamed node.
Custom aliases, global aliases and wildcards
| Kind | Where | What it does |
|---|---|---|
| Custom node alias | The URL aliases tab of a node | A further address of the node, for example a short campaign address. It either shows the node (direct) or redirects to its main address. |
| Global alias | Setup > URL translator (/content/urltranslator) | An address of your choosing for a module view or another address, for example login for user/login. |
| Wildcard | Setup > URL wildcards | A pattern such as news/* sent to articles/{1}. Consulted only when no alias matches; redirecting or not. |
| URL map import | Import above the URL translator (/content/urlimport) | Adds many old addresses at once from CSV, JSON, a spreadsheet or rewrite rules, with an undo. |
The settings
[URLTranslator] # translate readable addresses at all Translation=enabled # separator between words: dash, underscore or space WordSeparator=dash # the transform.ini group that makes aliases from names TransformationGroup=urlalias # the longest part of an alias (one path element), in characters; 0 for no limit UrlAliasNameLimit=255 # consult the wildcards when no alias matches WildcardTranslation=enabled
These are the defaults of settings/site.ini; change them in an override. Changing TransformationGroup or WordSeparator on a live site changes the aliases made from then on; existing aliases are only regenerated by bin/php/updateniceurls.php, which can change many addresses at once (history aliases redirect the old ones).
Where aliases are stored
All aliases are in the table ezurlalias_ml, one row per path element and language, with a flag for history entries and redirects. Wildcards are in ezurlwildcard. The Links, URL aliases, wildcards and search statistics guide describes the pages; moving a site with its old addresses is covered in URL maps.
Contributors
- Balazs Halasy
- Geir Arne Waaler
- Graham Brookins Updated Maintainer
Comments
Add a comment