How to remove the trailing slash from url’s at RealURL + typo3


I got my grade for some time racking their brains on how to the trailing slash, the RealURL automatically adds that slash if “defaultToHTMLsuffixOnPrev” is not set

http://www.example.com/artical/ -> http://www.example.com/artical

Here we have two solution for remove the trailing slash from url.

The following solution is extremely simple and banal, does not require any manipulation of the core files – only a “value” is entered in “defaultToHTMLsuffixOnPrev”.

First Solution

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'] = array (
    'fileName' => array (
        'defaultToHTMLsuffixOnPrev' => chr(0),
    ),
);

if some time its not workout that time you can use 
'defaultToHTMLsuffixOnPrev' => chr(1),

Second Solution

function user_encodeSpURL_postProc(&$params, &$ref) {
    if ($params['URL'] != '/') {
        $params['URL'] = preg_replace(
            '/\/($|\?|\#)/U',
            '\1',
            $params['URL']
        );
    }
}

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl'] = array (
    'EncodeSpURL_postProc' => array ( 'user_encodeSpURL_postProc'),
    '_DEFAULT' => Array (
    'Init' => array (
            // [...]
            'AppendMissingSlash' => 'ifNotFile'
            )
        // [...]
    )
);

URL will look like after applying above script :

www.example.com/artical

Second method may be not work for old version of realurl. so better we use first method

If you need trailing slash from url then simply use 0 in “defaultToHTMLsuffixOnPrev”

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'] = array (
    'fileName' => array (
        'defaultToHTMLsuffixOnPrev' => 0,
    ),
);

URL will look like after appling above script :

www.example.com/artical/

If you need trailing with .html from url then simply use 1 in “defaultToHTMLsuffixOnPrev”

$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT'] = array (
    'fileName' => array (
        'defaultToHTMLsuffixOnPrev' => 1,
    ),
);

URL will look like after appling above script :

www.example.com/artical.html

I hope today i make your day 😉

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

How to set 404 error handlers for multi-domain web-sites in Typo3


Multiple 404 error handlers for multi-domain web-sites + typo3

Its very important for multiple domain to set diffrent 404 error handlers

you can set following script in your local configuration


$TYPO3_CONF_VARS["FE"]["pageNotFound_handling_statheader"] = 'HTTP/1.1 404 Not Found';

if ($_SERVER['HTTP_HOST'] == 'www.jainishsenjaliya.com') {
     $TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = 'REDIRECT:http://jainishsenjaliya.com/404.html';
}
else {
     $TYPO3_CONF_VARS['FE']['pageNotFound_handling'] = 'REDIRECT:http://m.jainishsenjaliya.com/404.html';
}

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

How do i skip controller and action for tt_news in typo3


This is really necessary to remove extra parameter for SEO purpose

Following script will help you more. you need to set this typoscript in your setup file.

plugin.tx_news {
    settings {
        link {
            skipControllerAndAction = 1
        }
    }
}

After applying this controller and action will be removed from url

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

How to remove controller and action from realurl + typo3 extbase


This is very important part for SEO Base URL. So we must need to short URL.

We can remove the controller or the action in the RealURL config.

Following should do the trick, which will removes both action and controller from a detail-link.

'faq' => array(
    array(
        'GETvar' => 'tx_jsfaq_faq[action]',
        'valueMap' => array(
            'detail' => '',
        ),
        'noMatch' => 'bypass'
    ),
    array(
        'GETvar' => 'tx_jsfaq_faq[controller]',
        'valueMap' => array(
            'detail' => '',
        ),
        'noMatch' => 'bypass'
    ),
    array(
        'GETvar' => 'tx_jsfaq_faq[faq]',
        'lookUpTable' => array(
            'table' => 'tx_jsfaq_domain_model_faq',
            'id_field' => 'uid',
            'alias_field' => 'question',
            'addWhereClause' => ' AND NOT deleted',
            'useUniqueCache' => 1,
            'useUniqueCache_conf' => array(
                'strtolower' => 1,
                'spaceCharacter' => '-',
                ),
            'autoUpdate' => 1,
        ),
    ),
),	

I hope this will help you more. nojy 😉

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

Realurl configuration in realurl_conf.php file + typo3


The RealURL Configuration means to rewrite our URL to readable form and RealURL configuration is very useful for SEO purpose.

Following code need to put inside typo3conf folder

realurl_conf.php

<?php

$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(

    '_DEFAULT' => array(
        'init' => array(
            'enableCHashCache' => 1,
            'appendMissingSlash' => 'ifNotFile',
            'enableUrlDecodeCache' => 1,
            'enableUrlEncodeCache' => 1,
            'postVarSet_failureMode' => ''
        ),
        'redirects' => array(),
        'preVars' => array(
            array(
                'GETvar' => 'no_cache',
                'valueMap' => array(
                    'nc' => 1
                ),
                'noMatch' => 'bypass'
            ),
            array(
                'GETvar' => 'L',
                'valueMap' => array(
                    'en' => '0',
                    'de' => '1'
                ),
                'valueDefault' => 'de',
                'noMatch' => 'bypass'
            ),
        ),
        'pagePath' => array(
            'type' => 'user',
            'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
            'spaceCharacter' => '-',
            'languageGetVar' => 'L',
            'expireDays' => 7,
            'rootpage_id' => 1,
            'firstHitPathCache' => 1
        ),
        
        'fixedPostVars' => array(),
        
        'postVarSets' => array(
            '_DEFAULT' => array(
                
                
                // FAQ Extension
                'faq' => array(
                    array(
                        'GETvar' => 'tx_jsfaq_faq[faq]',
                        'lookUpTable' => array(
                            'table' => 'tx_jsfaq_domain_model_faq',
                            'id_field' => 'uid',
                            'alias_field' => 'question',
                            'addWhereClause' => ' AND NOT deleted',
                            'useUniqueCache' => 1,
                            'useUniqueCache_conf' => array(
                                'strtolower' => 1,
                                'spaceCharacter' => '-'
                            )
                        )
                    )
                ),
                
                // 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'
                        )
                    )
                ),
                
                // Ordering
                'order' => array(
                    array(
                        'GETvar' => 'tx_jscareer_career[order]'
                    ),
                ),
                // 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[backPid]'
                    ),
                    array(
                        'GETvar' => 'tx_ttnews[swords]'
                    )
                )
            )
        ),
        // configure filenames for different pagetypes
        'fileName' => array(
            'defaultToHTMLsuffixOnPrev' => 1,
            'index' => array(
                'print.html' => array(
                    'keyValues' => array(
                        'type' => 98
                    )
                ),
                'rss.xml' => array(
                    'keyValues' => array(
                        'type' => 100
                    )
                ),
                'rss091.xml' => array(
                    'keyValues' => array(
                        'type' => 101
                    )
                ),
                'rdf.xml' => array(
                    'keyValues' => array(
                        'type' => 102
                    )
                ),
                'atom.xml' => array(
                    'keyValues' => array(
                        'type' => 103
                    )
                )
            )
        )
    )
);

$TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT']['pagePath']['rootpage_id'] = 1; 
$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.YOUR-DOMIAN.com'] = $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT']; 

// this is for multi domain condfiguration

$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.YOUR-DOMIAN.de'] = $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT']; 
$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.YOUR-DOMIAN.de']['pagePath']['rootpage_id'] = 512;

$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.YOUR-DOMIAN.co.in'] = $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'];
$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.YOUR-DOMIAN.co.in']['pagePath']['rootpage_id'] = 9149;
?&gt

512 and 9149 is stand for root page id of each domain

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

How to get parameter values from href in jquery


 
For get a specific parameter value of url. you have to set below Javascript code

   var url = window.location.href;
   var queryStringIdx = url.indexOf('?');
   var pairs = url.substr(queryStringIdx + 1)
         .split('&')
         .map(function(p) { return p.split('='); });
   var result = { };
   for (var i = 0; i < pairs.length; i++) {
      result[decodeURIComponent(pairs[i][0])] = decodeURIComponent(pairs[i][1]);
   }

If your URL is “http://EXAMPLE.COM/index.php?id=8&uid=3&#8221;

and you want to get the value of uid then you have to use below code

   var uid = result['uid'];
   alert(uid);

Output :

3

If you have any queries, please do not hesitate to contact me at Jainish Senjaliya

Configuration of RealURL for use on more than one domain in the same database


 
If you have more then one root then you must have to set page root ID in realurl_conf.php

$TYPO3_CONF_VARS['EXTCONF']['realurl'] = array(
     '_DEFAULT' => array(
           'pagePath' => array(
               'type' => 'user',
               'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
               'rootpage_id' => 1
           ),
       ),

       'www.test.in' => array(
           'pagePath' => array(
               'type' => 'user',
               'userFunc' => 'EXT:realurl/class.tx_realurl_advanced.php:&tx_realurl_advanced->main',
               'rootpage_id' => 111
           ),
       )
  );

Notice how the rootpage_id field is set differently for these two cases!

$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.jainish.com'] = $TYPO3_CONF_VARS['EXTCONF']['realurl']['_DEFAULT'];
$TYPO3_CONF_VARS['EXTCONF']['realurl']['www.test.in'] = $TYPO3_CONF_VARS['EXTCONF']['realurl']['www.test.in'];

Another realurl configuration are here.. Please Click Here

If you have any query then feel free to contact me at Jainish Senjaliya