Discussion:
[TYPO3-english] RealURL - shortcut to home
Dennis Hoffland
2017-09-13 10:02:35 UTC
Permalink
Hello,

I am trying to configure RealURL to deliver a speaking URL home.html for my home page (in the menu).

My page structure is:
-home
---home (shortcut to home on root level above)
---page1
---page2

= Option 2 as suggested here: https://github.com/dmitryd/typo3-realurl/wiki/Notes-for-Integrators#home-page-root-page-and-shortcuts

I've tried the following code in realurlconf.php:

<?php
// [TYPO3_SITE_URL] [preVars] [pagePath] [fixedPostVars] [postVarSets] [fileName]

// [preVars] : language
// [pagePath] : page ID
// [fixedPostVars] :
// [postVarSets] : extension plugin(s)

/*
*
* RealURL setup for www.mydomain.com *
*
*/

$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
'_DEFAULT' => array(
// 'www.mydomain.com' => array(
'init' => array(
'enableCHashCache' => true,
'enableUrlDecodeCache' => true,
'enableUrlEncodeCache' => true,
'appendMissingSlash' => 'ifNotFile',
// 'postVarSet_failureMode' => 'ignore',
'emptyUrlReturnValue' => true,
),
'redirects' => array(),
'preVars' => array(
array(
'GETvar' => 'L',
'valueMap' => array(
'nl' => '1',
'en' => '2',
),
'valueDefault' => 'nl',
),
),
'pagePath' => array(
'type' => 'user',
'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
// 'spaceCharacter' => '_',
'languageGetVar' => 'L',
// 'expireDays' => 7,
###### Set your root page ID here ######
'rootpage_id' => 1,
// 'excludePageIds' => 1,
'dontResolveShortcuts' => true,
),
'fixedPostVars' => array(),
'postVarSets' => array(
'_DEFAULT' => array(
// news archive parameters
'archive' => array(
array(
'GETvar' => 'tx_ttnews[year]' ,
),
array(
'GETvar' => 'tx_ttnews[month]' ,
'valueMap' => array(
'january' => '01',
'february' => '02',
'march' => '03',
'april' => '04',
'may' => '05',
'june' => '06',
'july' => '07',
'august' => '08',
'september' => '09',
'october' => '10',
'november' => '11',
'december' => '12',
)
),
),
// news pagebrowser
'browse' => array(
array(
'GETvar' => 'tx_ttnews[pointer]',
),
),
// news categories
'select_category' => array (
array(
'GETvar' => 'tx_ttnews[cat]',
),
),
// news articles and searchwords
'article' => array(
array(
'GETvar' => 'tx_ttnews[tt_news]',
'lookUpTable' => array(
'table' => 'tt_news',
'id_field' => 'uid',
'alias_field' => 'title',
'addWhereClause' => ' AND NOT deleted',
'useUniqueCache' => 1,
'useUniqueCache_conf' => array(
'strtolower' => 1,
'spaceCharacter' => '-',
),
),
),
array(
'GETvar' => 'tx_ttnews[swords]',
),
),
),
),
'fileName' => array (
'defaultToHTMLsuffixOnPrev' => true,
'acceptHTMLsuffix' => false,
'index' => array(
'print.html' => array(
'keyValues' => array(
'type' => 98,
),
),
// add robots.txt page type
'robots.txt' => array(
'keyValues' => array(
'type' => 201
)
)
),


),

),
);
php?>

Instead of www.mydomain.com/home.html I get www.mydomain.com/1 as a link to my Home page in the menu. If I follow that link to the Home page and go back to the menu all speaking URL's are dropped!

My TS-setup contains the following code:

# *****
# RealURL
# *****

Setupconfig.simulateStaticDocuments = 0

config.prefixLocalAnchors = all
config.tx_realurl_enable = 1
config.uniqueLinkVars = 1
# config.defaultToHTMLsuffixOnPrev = 1

config.linkVars = L(0-2)

[globalVar = GP:L = 1]
config.sys_language_uid = 1
config.language = nl
config.locale_all = nl_NL.utf8

[globalVar = GP:L = 2]
config.sys_language_uid = 2
config.language = en
config.locale_all = en_UK.utf8

[GLOBAL]

Note: I am using Dutch (=nl) as only language in the FE.

My .htaccess file contains no extra code (simply oploaded the file from CMS 7.6.22).


Despite my very basic website setup and going through the realURL manual, I can't figure out how to solve this.

Who can offer help?

Kind regards,

Dennis
Jigal van Hemert
2017-09-13 14:08:21 UTC
Permalink
Hi,
Post by Dennis Hoffland
Hello,
I am trying to configure RealURL to deliver a speaking URL home.html for
my home page (in the menu).
-home
---home (shortcut to home on root level above)
---page1
---page2
The home page itself has the speaking URL "/" (as in
http(s)://domain.tld/ ). The 'home' subpage is a shortcut to the root
home and will thus have the same URL.
If the 'home' subpage would have a different URL then the content of the
home page would be available on two URLs; this is not desirable from an
SEO point of view.

You could give the home (root) page the path segment "home" if you set
it in the page properties. I'm not sure what you win by that and if it
has any side effects.
--
Jigal van Hemert
TYPO3 CMS Core Team Member

TYPO3 .... inspiring people to share!
Get involved: typo3.org
Dennis Hoffland
2017-09-13 14:56:36 UTC
Permalink
Hi Jigal,

I have no problem to settle with http(s)://www.mydomain.com/ instead of http(s)://www.mydomain.com/home.html, if the latter is difficult/impossible ...

Changing the Speaking URL path segment on the root page Home to "home" had no effect at all so far (doesn't show up in the URL, even after clearing the realURL tables in the DB).

Instead, with my current configuration, I keep getting http(s)://www.mydomain.com/1 (notice the trailing 1) as the "speaking" URL for the Home page in my menu. To make things worse the speaking URL's are "lost" completely if I continue navigating from my home page.

Any thoughts why that may be the case?

Thanks for the support so far.

Kind regards,

Dennis
Dennis Hoffland
2017-09-13 15:18:03 UTC
Permalink
Just to add some more information:

If I look at the tx_realurl_urldata table in the DB I notice that:
- the speaking URL of page 1 (the root page Home) = 1
- the speaking URL of page 2 (the shortcut page Home) = home.html

In short, realURL takes the speaking URL of page 1 instead op page 2 when rendering the links for the menu.

I also tried different values for dontResolveShortcuts (0, 1, false, true) in realurlconf.php, but with no effect.

Kind regards,

Dennis
Jigal van Hemert
2017-09-13 19:12:03 UTC
Permalink
Hi,
Post by Dennis Hoffland
Instead, with my current configuration, I keep getting
http(s)://www.mydomain.com/1 (notice the trailing 1) as the "speaking"
URL for the Home page in my menu. To make things worse the speaking
URL's are "lost" completely if I continue navigating from my home page.
First I would get rid of the _DEFAULT part; the manual states that it
can lead to problems and so far I haven't seen problems with the
installations that use the domain names there. You can simply refer to
the configurations of other domains in case you have to support domains
with and without www. prefix for example.
--
Jigal van Hemert
TYPO3 CMS Core Team Member

TYPO3 .... inspiring people to share!
Get involved: typo3.org
Dennis Hoffland
2017-09-14 09:04:27 UTC
Permalink
Hi Jigal,

I replaced _DEFAULT by www.mydomain.com as you suggested, but the speaking URL remains the same: www.mydomain.com/1

Except for the home page, everything seems to be working OK (speaking URLs are simply the page names, followed by .html).

As mentioned in my previous post the DB entries tell me even the speaking URL for the home page shortcut (id = 2) is generated as desired (home.html). However, it is somehow replaced by het speaking URL of the homepage itself (id = 1) in the menu.

Changing the values (0 or 1) for dontResolveShortcuts in the pagePath section of realurlconf.php doesn't seem te have any effect.

I am a bit lost here.

Would it be possible to post a realurlconf.php example of a working solution? Unfortunetly, https://github.com/dmitryd/typo3-realurl/wiki/Notes-for-Integrators#home-page-root-page-and-shortcuts only mentions the issue, but offers no code to resolve it.

Kind regards,

Dennis
Dennis Hoffland
2017-11-10 13:33:47 UTC
Permalink
This realurlconf.php works for me:

<?php
// [TYPO3_SITE_URL] [preVars] [pagePath] [fixedPostVars] [postVarSets] [fileName]

// [preVars] : language
// [pagePath] : page ID
// [fixedPostVars] :
// [postVarSets] : extension plugin(s)

$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
// '_DEFAULT' => array(
'www.mydomain.com' => array(
/*
'cache' => array(
'disable' => true,
),
*/
'init' =>
array(
'appendMissingSlash' => 'ifNotFile,redirect',
'emptyUrlReturnValue' => '',
),
'pagePath' =>
array(
'rootpage_id' => 1,
),
'fileName' =>
array(
'defaultToHTMLsuffixOnPrev' => 1,
'acceptHTMLsuffix' => 1,
'index' =>
array(
'print' =>
array(
'keyValues' =>
array(
'type' => 98,
),
),
'robots.txt' => array(
'keyValues' => array(
'type' => 201
)
)
),
),
'preVars' =>
array(
0 =>
array(
'GETvar' => 'L',
'valueMap' =>
array(
'nl' => 0,
'en' => 1,
),
'valueDefault' => 'nl'
),
),
'postVarSets' =>
array(
'_DEFAULT' =>
array(
'article' =>
array(
array(
'GETvar' => 'tx_news_pi1[action]',
),
array(
'GETvar' => 'tx_news_pi1[controller]',
),
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' => '-',
),
),
),
),
),
),
),
);
php?>


Mind you: the home page has no URL section (home.html). It simply gets the URL www.mydomain.com. Any suggestions to add the home.html to that are still welcome!
Loading...