Results 1 to 2 of 2
http://idgs.in/421387
  1. #1
    gegehare's Avatar
    Join Date
    Oct 2007
    Location
    root@linux:~#
    Posts
    5,365
    Points
    11.50
    Thanks: 153 / 213 / 165

    Default Redirect url dengan berbagai metode ( .htaccess , php , meta html )

    Ga perlu banyak basa basi ,
    ane buat trit ini karna disini keknya blm ada trit yg bahas ini CMIIW

    pdhl penting untuk SEO untuk hanya memilih satu antara akses dengan www atau non www

    langsung aja deh...

    Metode Dengan .htaccess :

    pertama2 buat dulu file .htaccess , caranya ? (untuk windows)
    - buka notepad , kosongkan , save di salah satu hdd ente (misal : d:/) dan beri nama htaccess.txt
    - start - run - ketik cmd - ok
    - change directory ke d: , ketik d: lalu enter
    - ketik REN htaccess.txt .htaccess

    setelah itu open with notepad file .htaccess nya lalu isi kan :

    1.untuk Redirect www to non www :

    Code:
    Options +FollowSymLinks 
    RewriteEngine on
    RewriteCond %{HTTP_HOST} .
    RewriteCond %{HTTP_HOST} !^example\.com
    RewriteRule (.*) http://example.com/$1 [R=301,L]
    2.untuk Redirect non www ke www :

    Code:
    Options +FollowSymLinks 
    RewriteEngine on 
    RewriteCond %{HTTP_HOST} ^example.com [NC] 
    RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
    3.untuk redirect example.com/index.php ke example.com/

    Code:
    Options +FollowSymLinks
    RewriteEngine on
    # index.php to /
    RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
    RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
    4.untuk redirect example.com/index.html ke example.com/index.php

    Code:
    RedirectMatch 301 (.*)\.html$ http://www.example.com$1.php
    5.untuk redirect oldpage.html ke newpage.html

    Code:
    Redirect 301 /oldpage.html http://www.example.com/newpage.html
    *301 : permanen redirect

    Metode dengan PHP :

    untuk redirect dari alamat lama ke alamat baru :

    Code:
    <?php
    Header("HTTP/1.1 301 Moved Permanently");
    Header("Location: http://www.example.com/");
    ?>
    Metode dengan meta HTML :

    taruh diantara tag <head>...</head> :

    Code:
    <meta http-equiv="refresh" content="10; url=http://example.com/">
    *10 : jumlah detik pengunjung sebelum ke redirect

    CMIIW ,

    TS belum mencoba semua
    hanya pernah mencoba redirect non www ke www
    and its works

    source

    Who is Trafalgar Law? The Captain and Doctor of the Heart Pirates? a Man with bounty 200.000.000 Beli? Surgeon of Death? No , He is just a Rookie Pirate who know the meaning about "Will of D."

    "I told you, I'm waiting for the right time...Dont get rushed, "One Piece" isn't going anywhere...Now, enough talking, Shut up and follow my orders...I'll be sure, To steal the proper throne" - Trafalgar Law

    GeGeHaRe One Piece Predictions
    New Nakama - Country Of Brigands - Wano Country - X Mark - Fire Sword

  2. Hot Ad
  3. #2
    Analyst's Avatar
    Join Date
    Apr 2011
    Location
    Rumah
    Posts
    6,058
    Points
    27.34
    Thanks: 8 / 260 / 200

    Default

    nice share kk..

    Metode PHP sama Meta udah saya coba..

    dan


    Its Works


    nice share


    ada tambahan dari saya

    Header("HTTP/1.1 301 Moved Permanently");
    bisa di edit jadi

    Header("HTTP/1.1 404 ");
    Header("HTTP/1.1 200");

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •