We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1434
    • 23 Posts
    Converting all static html and mixed with modx I have find a problem with url. In html static all links in body are relatives (or mostly) so when I include the base tag in head I lose all links. In the other hand if I don’t include the base tag all modx generated links becomes relative (i’m not using alias path). So I’m in a dilema.

    Inspired in a thread about getpage I have find a possible solution attaching a plugin on OnWebPagePrerender like this:

    <?php
    if ($modx->event->name === 'OnWebPagePrerender') {
        $output = $modx->resource->_output;
        $output = preg_replace('%href=(.)(?!/|http)%mis', 'href=$1/', $output);
        $modx->resource->_output = $output;
    }
    ?>
    


    But I don’t like the idea about launch a preg_replace on all render pages, a littel overhead. When site will be online I will use a reverse proxy with cache to prevent performance problem but, there is another more elegant way to do this ?

    Thanks.