• 24-04-2022, 20:39:36
    #1
    Merhaba: bir web sitemizin belli içeriklerini (200 adet) başka bir siteye ekledik. Fakat bu yazıların içerisindeki tüm linklemeleri kaldırmak istiyorum. Bunu nasıl yapabilirim? Link değiştirici veya herhangi bir kelimedeki linkleri değiştirmek istemiyorum. Sitenin makalelerinde bulunan kaynaklar kısımlarında linkler mevcut. Bunları toplu bir şekilde nasıl kaldırabilir veya etkisiz hale getirebilirim. Herhangi bir eklenti veya yöntem mevcut mu?
  • 24-04-2022, 20:43:36
    #2
    linklerin hepsi aynı domianmi

    function nofollow(string $html, string $baseUrl = null) {
        return preg_replace_callback(
                '#<a([^>]*)>(.+)</a>#isU', function ($mach) use ($baseUrl) {
                    list ($a, $attr, $text) = $mach;
                    if (preg_match('#href=["']([^"']*)["']#', $attr, $url)) {
                        $url = $url[1];
                        if (is_null($baseUrl) || !str_starts_with($url, $baseUrl)) {
                            if (preg_match('#rel=["']([^"']*)["']#', $attr, $rel)) {
                                $relAttr = $rel[0];
                                $rel = $rel[1];
                            }
                            $rel = 'rel="' . ($rel ? (strpos($rel, 'nofollow') ? $rel : $rel . ' nofollow') : 'nofollow') . '"';
                            $attr = isset($relAttr) ? str_replace($relAttr, $rel, $attr) : $attr . ' ' . $rel;
                            $a = '<a ' . $attr . '>' . $text . '</a>';
                        }
                    }
                    return $a;
                },
                $html
        );
    }
    functions.php içine eklerseniz tüm linklere nofollow verirsiniz.
  • 24-04-2022, 20:51:06
    #3
    webtasarimofisi adlı üyeden alıntı: mesajı görüntüle
    linklerin hepsi aynı domianmi

    function nofollow(string $html, string $baseUrl = null) {
        return preg_replace_callback(
                '#<a([^>]*)>(.+)</a>#isU', function ($mach) use ($baseUrl) {
                    list ($a, $attr, $text) = $mach;
                    if (preg_match('#href=["']([^"']*)["']#', $attr, $url)) {
                        $url = $url[1];
                        if (is_null($baseUrl) || !str_starts_with($url, $baseUrl)) {
                            if (preg_match('#rel=["']([^"']*)["']#', $attr, $rel)) {
                                $relAttr = $rel[0];
                                $rel = $rel[1];
                            }
                            $rel = 'rel="' . ($rel ? (strpos($rel, 'nofollow') ? $rel : $rel . ' nofollow') : 'nofollow') . '"';
                            $attr = isset($relAttr) ? str_replace($relAttr, $rel, $attr) : $attr . ' ' . $rel;
                            $a = '<a ' . $attr . '>' . $text . '</a>';
                        }
                    }
                    return $a;
                },
                $html
        );
    }
    functions.php içine eklerseniz tüm linklere nofollow verirsiniz.
    İşte sorunda domainde, domainlerin hepsi farklı. Bu tarz nofollow'u verebiliyoruz fakat benim istediğim şey tüm yazılardaki linkleri kaldırmak. Yanıtınız için teşekkürler
  • 24-04-2022, 21:09:17
    #4
    Faikyilmaz adlı üyeden alıntı: mesajı görüntüle
    İşte sorunda domainde, domainlerin hepsi farklı. Bu tarz nofollow'u verebiliyoruz fakat benim istediğim şey tüm yazılardaki linkleri kaldırmak. Yanıtınız için teşekkürler
    ozaman sqlden sorgulama yaparak kaldırabilirsiniz..