1. Halo Guest, pastikan Anda selalu menaati peraturan forum sebelum mengirimkan post atau thread baru.

#ASK Ubah Permalink

Discussion in 'Pemrograman Web' started by Mushlihin, Sep 17, 2018.

  1. Mushlihin

    Mushlihin Super Hero

    Joined:
    Oct 31, 2011
    Messages:
    839
    Likes Received:
    61
    Location:
    Belawa-Wajo
    Ceritanya, habis obrak abrik web nih...

    Nah, di blog saya ada ribuan hyperlink di post dengan permalink yang lama, modelnya: hxxx://nama domin. com/%year%/%monthnum%/%category%/%postname%.php

    Berhubung jumlahnya ribuan, saya mau ganti secara massal dengan model hxxx://namadomain(.)com/%postname%

    Udah googling gak nemu caranya. Udah coba macam2 plugin juga kagak bisa. Atau mungkin saya gk tahu caranya... Trims jika ada yang berkenan membagi ilmu :kacapembesar::malaikat::muah:
     
    Last edited: Sep 17, 2018
  2. Alva17

    Alva17 Ads.id Pro

    Joined:
    Apr 17, 2018
    Messages:
    281
    Likes Received:
    46
    plugin broken link
    bs edit skligus
     
  3. Mushlihin

    Mushlihin Super Hero

    Joined:
    Oct 31, 2011
    Messages:
    839
    Likes Received:
    61
    Location:
    Belawa-Wajo
    iTU MAH hanya pada link komentar. ini link pada postingan
     
  4. JAMBAL

    JAMBAL Ads.id Pro

    Joined:
    Aug 13, 2014
    Messages:
    261
    Likes Received:
    24
    Mungkin bisa pake fungsi ini
    PHP:
    function jmbl_mass_url_change($content) {
        if (
    is_single()) {
            function 
    replace($matches) {
                
    $new_url $matches[1];
                
    $anchor $matches[2];
                return 
    '<a href="'.$new_url.'">'.$anchor.'</a>';
            }
            echo 
    preg_replace_callback(
                
    '/<a.*href=["|\']https?:\/\/?namadomain.com\/[0-9]{4}\/[0-9]{2}\/.*\/(.*)\.php["|\'].*>(.*)<\/a>/',
                
    'replace',
                
    $content);
        } else { return 
    $content; }
    }
    add_filter('the_content','jmbl_mass_url_change');
    note: belom ditest :ninja:
     
    Last edited: Sep 17, 2018
  5. Alva17

    Alva17 Ads.id Pro

    Joined:
    Apr 17, 2018
    Messages:
    281
    Likes Received:
    46
    bisa pd semua elemen
    post, page, komentar, widget
     
  6. Mushlihin

    Mushlihin Super Hero

    Joined:
    Oct 31, 2011
    Messages:
    839
    Likes Received:
    61
    Location:
    Belawa-Wajo
    Coba link pluginnya. Sempat saya salah plugin. Makasih
     
  7. Mushlihin

    Mushlihin Super Hero

    Joined:
    Oct 31, 2011
    Messages:
    839
    Likes Received:
    61
    Location:
    Belawa-Wajo
    Dicoba bro. Eh tapi kalau kode nya seperti itu hanya satu yg berubah yaitu link bulan 4 tanggal 9 dst. Padahal model permalink nya, tahun tanggal bulan... coba bantu
     
  8. Alva17

    Alva17 Ads.id Pro

    Joined:
    Apr 17, 2018
    Messages:
    281
    Likes Received:
    46
    wordpress.org/plugins/broken-link-checker
     
  9. JAMBAL

    JAMBAL Ads.id Pro

    Joined:
    Aug 13, 2014
    Messages:
    261
    Likes Received:
    24
    Itu untuk permalink yg seperti ini
    Code:
    http://namadomain.com/2019/03/category-slug/post-name.php
    Kalo yang dimaksud seperti ini,
    Code:
    http://namadomain.com/2019/31/03/category-slug/post-name.php
    Coba yang ini
    PHP:
    function jmbl_mass_url_change($content) {
        if (
    is_single()) {
            function 
    replace($matches) {
                
    $new_url $matches[1];
                
    $anchor $matches[2];
                return 
    '<a href="'.$new_url.'">'.$anchor.'</a>';
            }
            echo 
    preg_replace_callback(
                
    '/<a.*href=["|\']https?:\/\/?namadomain.com\/[0-9]{4}\/[0-9]{2}\/[0-9]{2}\/.*\/(.*)\.php["|\'].*>(.*)<\/a>/',
                
    'replace',
                
    $content);
        } else { return 
    $content; }
    }
    add_filter('the_content','jmbl_mass_url_change');
     
  10. Tapuy

    Tapuy Ads.id Pro

    Joined:
    May 15, 2014
    Messages:
    358
    Likes Received:
    82
    Maaf gan, bisa bantu ane gak gan kalau mengubah link di artikel dari

    namadomain^com/2017/10/cara-buat-wordpress-responding.html

    menjadi:
    namadomain^com/cara-buat-wordpress-responding/


    bagaimana ya gan?
     
  11. luluilma

    luluilma Newbie

    Joined:
    Mar 15, 2016
    Messages:
    4
    Likes Received:
    0
    ini pakai wordpress kan? di setting>permalink tetep gitu keluarnya ya?

    Sent from my MI MAX 2 using Tapatalk
     
  12. JAMBAL

    JAMBAL Ads.id Pro

    Joined:
    Aug 13, 2014
    Messages:
    261
    Likes Received:
    24
    Coba ini gan
    PHP:
    // http://namadomain.com/2017/10/post-name.html --> http://namadomain.com/post-name/

    function jmbl_mass_url_change($content) {
        if (
    is_single()) {
            function 
    replace($matches) {
                
    $home $matches[1];
                
    $new_url $matches[2];
                
    $anchor $matches[3];
                return 
    '<a href="'.$home.''.$new_url.'/">'.$anchor.'</a>';
            }
            echo 
    preg_replace_callback(
                
    '/<a.*href=["|\'](https?:\/\/?namadomain.com\/)[0-9]{4}\/[0-9]{1,2}\/(.*)\.html["|\'].*>(.*)<\/a>/',
                
    'replace',
                
    $content);
        } else { return 
    $content; }
    }
    add_filter('the_content','jmbl_mass_url_change');
     
    Last edited: Sep 21, 2018
    Tapuy likes this.
  13. JAMBAL

    JAMBAL Ads.id Pro

    Joined:
    Aug 13, 2014
    Messages:
    261
    Likes Received:
    24
    PHP:
    // http://namadomain.com/2019/03/category-slug/post-name.php --> http://namadomain.com/post-name

    function jmbl_mass_url_change($content) {
        if (
    is_single()) {
            function 
    replace($matches) {
                
    $home $matches[1];
                
    $new_url $matches[2];
                
    $anchor $matches[3];
                return 
    '<a href="'.$home.''.$new_url.'">'.$anchor.'</a>';
            }
            echo 
    preg_replace_callback(
                
    '/<a.*href=["|\'](https?:\/\/?namadomain.com\/)[0-9]{4}\/[0-9]{2}\/[a-zA-Z0-9-]+\/(.*)\.php["|\'].*>(.*)<\/a>/',
                
    'replace',
                
    $content);
        } else { return 
    $content; }
    }
    add_filter('the_content','jmbl_mass_url_change');
    PHP:
    // http://namadomain.com/2019/31/03/category-slug/post-name.php --> http://namadomain.com/post-name

    function jmbl_mass_url_change($content) {
        if (
    is_single()) {
            function 
    replace($matches) {
                
    $home $matches[1];
                
    $new_url $matches[2];
                
    $anchor $matches[3];
                return 
    '<a href="'.$home.''.$new_url.'">'.$anchor.'</a>';
            }
            echo 
    preg_replace_callback(
                
    '/<a.*href=["|\'](https?:\/\/?namadomain.com\/)[0-9]{4}\/[0-9]{2}\/[0-9]{2}\/[a-zA-Z0-9-]+\/(.*)\.php["|\'].*>(.*)<\/a>/',
                
    'replace',
                
    $content);
        } else { return 
    $content; }
    }
    add_filter('the_content','jmbl_mass_url_change');
     
  14. Tapuy

    Tapuy Ads.id Pro

    Joined:
    May 15, 2014
    Messages:
    358
    Likes Received:
    82
    Akhirnya .... Terima kasih banyak gan, sudah dicoba berhasil!!

    Oh iya gan apa bisa gan kalau script tersebut dicopot link nya berubah permanen? pas ane copot scriptnya, link nya balik lagi seperti semula. Jadi sistemnya kayak update url gitu gan, gak balik lagi linknya kayak dulu tapi ke yang baru dan itu permanen.
     
  15. JAMBAL

    JAMBAL Ads.id Pro

    Joined:
    Aug 13, 2014
    Messages:
    261
    Likes Received:
    24
    Iya gan kalo dicopot ya ga running donk script nya hehe..
    Kalo mengubah permanen itu urusannya sama database gan, dan saya ga ngerti :chicken:
     
  16. Beny Benz

    Beny Benz Ads.id Pro

    Joined:
    Jun 24, 2018
    Messages:
    279
    Likes Received:
    50
    Location:
    Indonesia
    Kalau utk wordpress, masuk ke setting, trus pilih permalink trus pilih custom, kemudian masukan kode %postname% pada kotak yg tersedia.

    Sent from my A1603 using Tapatalk
     
  17. JAMBAL

    JAMBAL Ads.id Pro

    Joined:
    Aug 13, 2014
    Messages:
    261
    Likes Received:
    24
    Bukan itu yang ditanyakan gan :senyum:
     
  18. Tapuy

    Tapuy Ads.id Pro

    Joined:
    May 15, 2014
    Messages:
    358
    Likes Received:
    82
    ok gan makasih itu script nya....
     
  19. topenk

    topenk Ads.id Pro

    Joined:
    Nov 23, 2011
    Messages:
    367
    Likes Received:
    12
    Location:
    Di sini
    script ini di taruh dimana om, maaf gak ngerti. pengen ngrubah permalink seperti ente juga :)
     

Share This Page