Cara Redirect Berdasarkan UserAgent

Discussion in 'Masalah Teknik dan Keamanan' started by ronijoger, 23 May 2015.

Thread Status:
Not open for further replies.
  1. ronijoger

    ronijoger Beginner 1.0

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Hello semuanya,

    Saya punya pertanyaan seperti ini:

    Bagaimana cara membuat redirect useragent tertentu (misalnya Firefox) dari url tertentu ke url tertentu pada .htaccess

    Contoh:

    Kalau ada useragent Firefox visit url saya misalnya:

    Code:
    http://blablabla.com/ini-contoh-url/
    kemudian saya redirect ke url lainnya

    Note:

    Saya sudah coba menggunakan code:

    Code:
    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} Firefox
    RewriteRule ^/?ini-contoh-url/?$ http://newurl.com/this-url/ [L,R=301]
    Tapi tidak bisa

    Terima kasih buat bantuannya
     
  2. mustafaramadhan

    mustafaramadhan Hosting Guru

    Messages:
    3,237
    Likes Received:
    857
    Trophy Points:
    113
  3. ronijoger

    ronijoger Beginner 1.0

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Thanks pak Mus

    Sudah di coba pak tapi tidak bisa

    coba bapak baca thread saya juga di http://forum.joomla.org/viewtopic.php?f=712&t=888490

    I tried it for root domain and it's work but when I try to my url is't not work

    I will give you sample....

    Please use your firefox first

    then visit:

    gordenminimalis.web.id


    RewriteEngine On
    RewriteCond %{HTTP_HOST} gordenminimalis.web.id$ [NC]
    RewriteCond %{HTTP_USER_AGENT} Firefox [OR]
    RewriteCond %{HTTP_USER_AGENT} msnbot [OR]
    RewriteCond %{HTTP_USER_AGENT} Slurp
    RewriteRule ^(.*)$ http://bing.com/$1 [L,R=301]


    After that change your browser + visit again

    I try it with chrome and it's work (no redirect to bing)

    masalahnya itu kalau yang di redirectnya url nya yang belum ketemu jawabannya

    thank pak
     
  4. mustafaramadhan

    mustafaramadhan Hosting Guru

    Messages:
    3,237
    Likes Received:
    857
    Trophy Points:
    113
    Maksud anda untuk '^/?ini-contoh-url/?$' apa (terutama tanda '?').
     
  5. ronijoger

    ronijoger Beginner 1.0

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
  6. mustafaramadhan

    mustafaramadhan Hosting Guru

    Messages:
    3,237
    Likes Received:
    857
    Trophy Points:
    113
    Saya pikir anda salah mengartikan tentang '^/?ini-contoh-url/?$' (tidak paham dengan 'regular expression').

    Pakai 'RewriteRule ^(.*)$ http://newurl.com/this-url/$1 [L,R=301]' apa tidak cukup?.
     
  7. masiqbal

    masiqbal Expert 2.0

    Messages:
    863
    Likes Received:
    249
    Trophy Points:
    43
    Alternatif selain pakai .htaccess bikin di PHP nya.
     
  8. ronijoger

    ronijoger Beginner 1.0

    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Kalau di root domain bisa pak tapi kalau untuk url gak bisa. untuk regex nya apa ya tipenya? regex .Net, Perl, Xpath atau regex apa gitu? saya cuma tau regex .Net soalnya.

    Belum coba mas nanti mau sy coba karena lebih simple pake htaccess kyk nya

    Thanks
     
Loading...
Thread Status:
Not open for further replies.

Share This Page

Loading...