Skip to content

Bagaimana membuat statement pada semua site url atau domain menjadi "/" saja? #280

Discussion options

You must be logged in to vote

Kalau nggak salah itu sudah ditangani oleh mecha-cms/x.minify. Tapi kalau tujuannya cuma untuk menghapus domain bisa sih, kira-kira begini:

Hook::set('content', function ($content) {
    if (!$content || false === strpos($content, '://')) {
        return $content;
    }
    $host = $_SERVER['HTTP_HOST'];
    $content = strtr($content, [
        'http://' . $host . '/' => '/',
        'http://' . $host . '?' => '?',
        'http://' . $host . '#' => '#',
        'http://' . $host . '"' => '/"',
        "http://" . $host . "'" => "/'",
    ]);
    // dst...
    // $content = strtr(...);
    return $content;
});

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@bungfrangki
Comment options

@bungfrangki
Comment options

@taufik-nurrohman
Comment options

Answer selected by bungfrangki
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
x.minify Minify extension.
2 participants