.htaccess - url segments based redirect in modx Evo -
let's have url entered in modx evo
www.zipit.com.org/reference/toamovie/
if have page called toamovie
parent called reference
but when enters url want equivalent of this
www.zipit.com.org/reference.html?myvar=toamovie
additionally, or more importantly, i'd result more this, 12
wouls id of document
`www.zipit.com.org/reference.html?myid=12'
i'm wondering if @ possible modx evolution.i'm thinking should possible htaccess magic, first part anyway. how value document? quite inaccessible htaccess, there need part plug database , value.
it should possible custom plugin called on "onpagenotfound" event.
<?php $url = $_server['request_uri']; //get url //split url pieces , remove empty values $pieces = array_filter(explode('/', $url)); //reset array keys $temp = array(); foreach ($pieces $piece) { $temp[] = $piece; } $pieces = $temp; //basic checking of url if (count($pieces) == 2) { $modx->sendredirect('http://www.zipit.org/' . $pieces[0] .".html?myid=" . $pieces[1]); } ?>
remember plugins aren't wrapped in php tags. script pass incorrect urls zipit.org. error handling desireable.
Comments
Post a Comment