简体   繁体   中英

modx redirect infinite loop

I am using Modx revolution latest version. i want to create a plugin it will check current page url. some cases when current url match a given pattern then i want to redirect to a new url.

My first query is: if i go and wrong-uri is not exists it goes to .in that case if my current url is then what will be resource id ??? 并且不存在错误的uri,它将转到这种情况下,如果我当前的网址是那么什么是资源ID?

my second query is: i've done this :

if ($modx->event->name == 'OnWebPagePrerender'){
$id = $modx->resource->get('id');
$curUrl = $modx->runSnippet('getCurrentPage',array('id' =>$id)); 
$output = &$modx->resource->_output;
$redUrl ="http://".$_SERVER['HTTP_HOST'].'/custom/';             
if(($curUrl !=$redUrl)&&  $curUrl == ("http://".$_SERVER['HTTP_HOST']."/")){



$modx->sendRedirect($redUrl);               
}
return ;
}

browser says that is in infinite redirect loop.why?

is this plugin called multiple times?? then what would be the appropriate event for this plugin ?? thanks in advance ...

Yes i got it after all day ....!!! for www.mydomain.com/wrong-uri my $curUrl is www.mydomain.com/. so always if getting true and i'm in infinite loop.

If i go www.mydomain.com/wrong-uri and wrong-uri is not exists it goes to the page with id specified in the system setting error_page . And maybe http://rtfm.modx.com/display/revolution20/Plugins#Plugins-PageNotFoundRedirector%3A will help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM