-
Notifications
You must be signed in to change notification settings - Fork 126
Configuration reference
This page serves as a reference-only. If you do not know how to configure RealURL, visit a "Manual configuration" page to see how to configure the extension.
Table of contents
- cache section
- init section
- fileName section
- pagePath
- preVars
- fixedPostVars
- postVarSets
- Request Variable Definition
- _DOMAINS
The cache section controls the behavior of RealURL related to the cache.
type: string
default: /tx_solr|tx_indexed_search|(?:^|\?|&)q=/
This option defines a regular expressions for URLs that should not be cached. Typically those are URLs with unpredictable, free form search strings, like ones from EXT:solr or EXT:indexed_search. The default expression bans URLs from those search engines from polluting the cache.
Note that there is no check for validity of the expression. If the expression is invalid, the cache will behave unpredictably.
type: boolean
default: false
Disabled RealURL cache. This should never be set to true
in production because of performance reasons.
The init section contains options that define generic behaviour of RealURL.
type: boolean/string
default: ifNotFile,redirect[301]
If set, the a trailing slash will be added internally to the path if it was not set by the user. For instance someone writes "http://the.site.url/contact" with no slash in the end. "contact" will be interpreted as the filename by RealURL – and the user wanted it to be the directory. So this option fixes that problem. Note that usually such redirection is handled by the Apache web server, so just setting this to true
does not make much sense.
Keywords are separated by comma. There must be no spaces between keywords. The order of keywords in this directive is not significant. Notice that this directive processed after the processing hook but before any other directive (even before redirects). Therefore all other directives will see URL with the appended slash if this directive is set. For redirects it means that redirect patterns must have slashes in the end (“/path/”, not just “/path”) to be recognized.
Keyword: "ifNotFile"
You can specify the option as the keyword "ifNotFile". If you use that string as value the slash gets prepended only if the last part of the path doesn't look like a filename (based on the existence of a dot "." character).
Keyword: "redirect"
This keyword will force RealURL to redirect to the location with appended slash. This will ensure that pages do not appear doubled in the Google index (and therefore page rank does not suffer). Notice that it is not the same as redirect action described in the ->actionConfig later in this manual.
The keyword can be optionally followed by the HTTP status code to use for redirect in the square brackets (for example, “redirect[301]”). The following codes are allowed: 301, 302, 303, 307. Redirect will be processed after “ifNotFile”.
type: string
default: empty
If the segment is empty when encoding, use this value. This may prevent empty segments from appearing in the URL (path/to////page
). Note that generally empty segments is a sign of a bad configuration.
When empty segments appear in the URL, decoding can be complicated and may fail unless the URL is in the cache.
type: string
default: empty
If you set this value to a string, that will be the URL returned if the URL is otherwise empty (usually empty URL means home page).
type: string
default: empty
When the postVarSet is not found fo the URL segment, this option defines how to handle it. Possible solutions are defined by one of the keywords listed below.
redirect_goodUpperDir
With this keyword RealURL will stop processing URL segments and will immediately redirect the request to a good processed part of the path.
ignore
With this keyword RealURL will just stop processing URL segments. Potentially this mode is not good for SEO because it can create duplicate content issues.
empty value
Empty value (default) will cause the 404 page with the message that looks like Segment "test" was not a keyword for a postVarSet as expected on page with id=12345
. Usually this is the best solution because produces the expected result for the URL that does not exist.
type: boolean
default: false
If config.absRefPrefix is set in TypoScript setup, RealURL will strip this prefix before making the final URL. Use this option to reapply the prefix. By default it is not set, so prefix will be lost by default.
If you use linking across domains, do not put full domain name in config.absRefPrefix. Use only “/” as prefix.
The fileName section defines how RealURL treats the last segment of the URL. It is possible to make the URL look like /path/to/news/item/ or /path/to/news/item.html or have something like rss.xml in the end and to decode it to a certain page type.
type: boolean/string
default: true
If set to boolean, defines whether RealURL will treat URLs ending to / or .html identically. It can also be set to a string to limit the suffix to a certain value. The value must include a dot (example: .html
)
type: boolean/string
default: false
Identical to #acceptHTMLsuffix for decoding (and overrides it) but also used for encoding of URLs. Same format as acceptHTMLsuffix
.
type: array
default: empty
Allows to encode/decode request variables to a file name. For example:
'fileName' => array (
'index' => array(
'print.html' => array(
'keyValues' => array(
'type' => 98
)
),
'rss.xml' => array(
'keyValues' => array(
'type' => 76
)
)
)
)
This configuration will convert 'type' GET parameter to either print.html
or rss.xml
depending on the value of the parameter. Decoding will set the value of $_GET
accordingly.
This section defines parameters that help RealURL to determine correct root page of the site.
Note: version 1.x of RealURL required a userFunc
parameter in this section. RealURL 2.x does not use this parameter any more and it has no effect. Also languageGetVar
is not used and its value is always assumed to be standard TYPO3 L
.
type: integer
default: empty
This option is strongly recommended to be set in all cases. While RealURL is often able to discover root page id correctly from domain records, it is better to set this value manually in the configuration.
This section defines the configuration of preVars. It is an array of variable definitions.
Note: preVars
apply to all pages and cannot be set per page. Typically preVars
should be limited to simple variables like L
or no_cache
.
Example:
'preVars' => array(
array(
'GETvar' => 'L',
'valueMap' => array(
'de' => 0,
'fr' => 1,
'it' => 2,
),
'noMatch' => 'bypass',
),
array(
'GETvar' => 'no_cache',
'valueMap' => array(
'nc' => 1,
),
'noMatch' => 'bypass',
),
),
Fixed postVars are defined for specific pages. Usually they are not defined for all pages of the site. 'Fixed' means that they must be set. Typical examples are detail ("single view") pages for extensions like news or addresses, where you always need to show only the detail view and do not want an extra prefix in the URL like for postVarSets.
This section is an array. Keys are either page ids or aliases. Values are either strings or arrays. If it is a string, it is assumed to be an alias that points either to another alias or to an array with variable definitions. There is a limit to 10 nesting of aliases.
Aliases are useful if you want to reuse the configuration for more than one page.
Example:
'fixedPostVars' => array(
'newsDetail' => array(
array(
'GETvar' => 'tx_news_pi1[news]',
'lookUpTable' => array(
'table' => 'tx_news_domain_model_news',
'id_field' => 'uid',
'alias_field' => 'title',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
),
10 => 'newsDetail',
384 => 'newsDetail',
),
Note that you could also have 10
set to the variable definition and 384 => 10
as an alias.
You should not use fixedPostVars for all pages!
This section describes postVarsSets – the most frequently used part of RealURL.
postVarsSets define a group of variables with the common prefix. One such group is a postVarSet. For example, you could combine all variables for news detail view like this:
'postVarSets' => array(
'_DEFAULT' => array(
'news' => array(
array(
'GETvar' => 'tx_news_pi1[controller]',
'valueMap' => array(
'news' => 'News',
)
),
array(
'GETvar' => 'tx_news_pi1[action]',
),
array(
'GETvar' => 'tx_news_pi1[news]',
'lookUpTable' => array(
'table' => 'tx_news_domain_model_news',
'id_field' => 'uid',
'alias_field' => 'title',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
),
),
),
),
news
is a postVarSet prefix. The URL produced by this configuration will look like /..../news/news/detail/my-news-item-title/
. Here the first news
segment is a postVarSet prefix, the second comes from the 'GETvar' => 'tx_news_pi1[controller]'
and so on.
Notice the _DEFAULT
keyword at the second line of the example above. It tells RealURL that postVarSets under it can be used for any page. If you want to limit postVarSets to specific pages, use exact page ids. For example:
'postVarSets' => array(
'_DEFAULT' => array(
'news' => array(
array(
'GETvar' => 'tx_news_pi1[controller]',
'valueMap' => array(
'news' => 'News',
)
),
array(
'GETvar' => 'tx_news_pi1[action]',
),
array(
'GETvar' => 'tx_news_pi1[news]',
'lookUpTable' => array(
'table' => 'tx_news_domain_model_news',
'id_field' => 'uid',
'alias_field' => 'title',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
),
),
),
35 => array(
'news' => array(
array(
'GETvar' => 'tx_anothernews_plugin[newsId]',
'lookUpTable' => array(
'table' => 'tx_anothernews_domain_model_news',
'id_field' => 'uid',
'alias_field' => 'title',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
),
),
)
),
RealURL first checks for the current page id. If it exists, it uses that configuration and _DEFAULT
is ignored. If no configuration exist for the current page, _DEFAULT
is used. Aliases can be used too. See description of fixedPostVars for more information about aliases.
Request variable definitions are used for preVars, fixedPostVars and postVarSets. Each definition is an array with one mandatory entry that defines the name of the variable and zero or more transformation entries. Each transformation entry is processed according to priority:
If no transformations are set or triggered, the value is used as is. Note that for "as is" there is no any kind of conversion except for the usual rawurlencode
. If one transofmration triggered, other transformations are skipped.
type: string
This is a mandatory option. It defines the name of a request variable that will be mappend to a URL segment. Example:
array(
'GETvar' => 'tx_news_pi1[news]'
)
valueMap
maps segment value to the raw value. For example:
array(
'GETvar' => 'L',
'valueMap' => array(
'de' => 0,
'fr' => 1,
'it' => 2,
),
),
In this example, $_GET['L']
will be transformed to either de
, or fr
, or it
during the decoding depending on the value of $_GET['L']
. During the decoding, the segment will be converted back to the request variable.
If valueMap
did not trigger, noMatch
will attempt to trigger. noMatch
transformation has two possible states:
bypass
This state will just stop resolution of variable. This is useful if you want to have the segment only in certain cases. For example:
array(
'GETvar' => 'L',
'valueMap' => array(
'fr' => 1,
'it' => 2,
),
'noMatch' => 'bypass',
),
This will create URLs with /fr/
and /it/
when $_GET['L']
is 1
or 2
but will not create anything for 0
. This is useful for having shorter URLs for the default language, for example.
null
This will set the segment to the empty value. This mode is rarely used.
userFunc allows to transform the variable though the custom PHP code.
The function receives an array with the following parameters:
-
decodeAlias
–false
for encoding andtrue
for decoding -
pObj
– a reference to the calling class -
value
– current variable value -
pathParts
– a reference to the array with segments. The function must remove processed segments for decoding and append them for encoding. -
setup
- a configuration for the current variable.
The returned value must be either numeric or string.
lookUpTable
allows to convert an id value to a readable string. Typically uid
value is converted to a record of the title.
The following options can be set:
-
table
sets the name of the table to use for transoformation -
id_field
is the name of the field to use. For standard TYPO3 tables this will be theuid
field -
alias_field
is a field to use to create a string. You can also use MySQL function here likeCONCAT('title', '-', uid)
-
addWhereClause
is an additional WHERE clause that must start with' AND'
. For example:' AND deteled=0 AND hidden=0'
. -
maxLength
is the maximum possible length of the alias -
useUniqueCache
should be set totrue
. If set tofalse
, there can be problems during decoding -
languageField
is an options field that defines what field in th table contains language id of the record. Typically it issys_language_uid
. Same as[ctrl][languageField]
in$TCA
-
transOrigPointerField
is the same as[ctrl][transOrigPointerField]
in$TCA
for the table -
languageExceptionUids
defines languages where translation will not be used (you may want to use language title for asian languages, for example) -
useUniqueCache_conf['strtolower']
should be set totrue
generally and converts the alias to the lower case -
useUniqueCache_conf['spaceCharacter']
defines a replacement for the space charater in the alias -
enable404forInvalidAlias
will produce a 404 page in case if the alias cannot be resolved
Example:
array(
'GETvar' => 'tx_news_pi1[news]',
'lookUpTable' => array(
'table' => 'tx_news_domain_model_news',
'id_field' => 'uid',
'alias_field' => 'title',
'useUniqueCache' => true,
'useUniqueCache_conf' => array(
'strtolower' => true,
'spaceCharacter' => '-',
),
),
),
If none of previous transformations triggered, allows to set a default value. Note that the value is a URL segment value. RealURL will try to look in the valueMap
for this value when decoding. If the value is not found, it will set it as is.
_DOMAINS
configuration allows you to set domain name for the links according to a value of the $_GET
parameter. Most often it happens for languages. See this blog post for the description of the feature.