Can you confirm you have the plugin enabled and set to fire on the WebPageInit event?
Plugin Disabled box is unchecked
WebPageInit box is checked
Confirmed
www.JBMWebDesign.com
www.JBMAutomation.com
Here is what the
core/cache/includes/elements/modplugin/9.include.cache.php
looks like.
<?php
function elements_modplugin_9($scriptProperties= array()) {
global $modx;
if (is_array($scriptProperties)) {
extract($scriptProperties, EXTR_SKIP);
}
//check we are acting on the right system event - in this case onWebPageInit
switch($modx->event->name){
case 'onWebPageInit':
//check if we have the PHPSESSID parameter in our querystring
if (isset($_GET['PHPSESSID'])) {
//if so, strip it out
$requesturi = preg_replace('/&PHPSESSID=[^&]+/',"",$_SERVER['REQUEST_URI']);
$requesturi = preg_replace('/PHPSESSID=[^&]+/',"",$requesturi);
$requesturi = preg_replace('/(\?)$/',"",$requesturi);
//give Google a 301 response so it knows this redirect to our clean url is permanent
header("HTTP/1.1 301 Moved Permanently");
//redirect to our clean URL
header("Location: http://".$_SERVER['HTTP_HOST'].$requesturi);
exit;
}
break;
}
}
www.JBMWebDesign.com
www.JBMAutomation.com
Swapped out the code for you just posted and get an error:
Parse error: syntax error, unexpected T_STRING in /home1/jbmaudio/public_html/core/cache/includes/elements/modplugin/9.include.cache.php on line 17
It seems the error is in this line:
header("Location: <a href="<a href="http://".$_SERVER['HTTP_HOST'].$requesturi"" target="_blank" rel="nofollow">http://".$_SERVER['HTTP_HOST'].$requesturi"</a>
www.JBMWebDesign.com
www.JBMAutomation.com
Ok, I took the code from your blog and it is seems to be working now that you made the changes.
<?php
//check we are acting on the right system event - in this case onWebPageInit
switch($modx->event->name){
case 'OnWebPageInit':
//check if we have the PHPSESSID parameter in our querystring
if (isset($_GET['PHPSESSID'])) {
//if so, strip it out
$requesturi = preg_replace('/(&|\?)PHPSESSID=[^&]+/','',$_SERVER['REQUEST_URI']);
$requesturi = preg_replace('/(\?)$/',"",$requesturi);
//give Google a 301 response so it knows this redirect to our clean url is permanent
header("HTTP/1.1 301 Moved Permanently");
//redirect to our clean URL
header("Location: http://".$_SERVER['HTTP_HOST'].$requesturi);
exit;
}
break;
}
But the code you just posted, i get errors with.
www.JBMWebDesign.com
www.JBMAutomation.com
The parser here is injecting a link into the code because it sees a 'http://' in it - that is what is breaking the code - have updated the blog post to reflect the final code.
Everything seems to be working now.....thanks!
www.JBMWebDesign.com
www.JBMAutomation.com
My next question is this. My host won't let me add these lines to the .htaccess file.
php_flag session.use_trans_sid off
php_flag session.use_only_cookies on
it says i need to use the php.ini file
is there a way around this?
www.JBMWebDesign.com
www.JBMAutomation.com