KOTAK HITAM : The Blackbox of Nothingman
  Thursday, September 9, 2010
Linux Corner
Login
Username

Password



Not a member?
Sign Up Here!

Lost Password?
Menu
Users Online
 Guests Online: 1
 Members Online: 0

Total Members: 80
Newest Member: Supitra
Last Seen Member
pakdhetimin18:55:18

IP Address : 66.96.249.197
Web Browser : Other
Powered by
Kios Domain
CO.CC:Free Domain

DONATION
Help us to develop opensource cms for everyone.
Donate us through Paypal :


Stats n Rank

Advanced PHP Script URL Redirection

Berikut contoh cara redirection URL web page ke URL lain menggunakan script PHP yang langkah-langkah dasarnya telah dijelaskan pada artikel lain, dan ini adalah contoh konkrit penggunaan Redirection URL menggunakan script PHP:

  • Buat file PHP dengan nama redirect.php dan isi konten script didalamnya adalah sebagai berikut:
    <?php
    header( 'Location: http://www.kotakhitam.com/search.php' ) ;
    ?>

  • upload dan letakkan file tersebut di root directory website anda dan sebagai contoh saya letakkan di root directory situs www.kotakhitam.com.
  • Buatlah file .htaccess dengan Notepad [Windows] atau Text editor Linux dan isi konten sebagai berikut:
    ErrorDocument 404 /redirect.php

    Upload file .htaccess tersebut di root directory web anda


Silahkan dicoba dengan mengakses URL misal: http://www.kotakhitam.com/file-tidak-ada.php maka secara otomatis akan dipanggil atau dieksekusi file redirect.php yang menginformasikan bahwa alamat yang diakses tidak ditemukan, setelah itu URL akan dialihkan menuju ke http://www.kotakhitam.com/search.php

Selamat mencoba.

CATATAN: Ini dengan asumsi server hosting web anda menggunakan Linux Apache server.
Comments
#1 | mawi wijna on July 20 2010
kosek Pakdhe, di-redirect ke error 404 trus di-redirect ke search?

berarti halaman error 404 ndak bakal pernah terbuka klo pake metode ini. Krn user langsung di-redirect ke search.
#2 | pakdhe timin on July 20 2010
oh iya dink..user langsung menuju search.php kalau mereka terkena metode 404 Page Not Found..hehe..

langsung dengan .htaccess juga bisa dink menuju search.php..hehe..lah aku bingung mau buat contoh jew..:D

jadi isi file .htaccess seperti ini:
Code
ErrorDocument 404 /search.php




artikel telah saya perbarui dengan mengganti nama file 404.php menjadi redirect.php
dan isi file .htaccess adalah seperti ini:
Code
ErrorDocument 400 /redirect.php
ErrorDocument 401 /redirect.php
ErrorDocument 403 /redirect.php
ErrorDocument 404 /redirect.php
ErrorDocument 500 /redirect.php



maaf..maaf..:(
Post Comment
Name:

Validation Code:

Latest ArticlesMost Read Articles
Eyangku Pejuang Tangguh
Hachiko: A Dog Story
Tips jika kena Tilang Polisi
Countdown Timer with Flash A...
Advanced PHP Script URL Redi...
Tutorial Hacking
Geronimo
Installing Windows XP on Com...
Meta Tags Explained
Download Video dari YouTube
Latest UploadsPopular Downloads
Themes Merah Putih v7 -dl: 55 times
Extended Online User Panel v... -dl: 48 times
Most Read Articles Panel v7 -dl: 49 times
Similitude White Theme -dl: 51 times
Weather Panel v6 -dl: 56 times
Virus Threats Panel v6 -dl: 48 times
Center Lower Panel v7 -dl: 47 times
Darken Theme KotakHitam -dl: 58 times
Similtude Black Theme -dl: 52 times
Sex Education -dl: 23 times
Indonesian Language Pack v7 -dl: 69 times
Darken Theme KotakHitam -dl: 58 times
Weather Panel v6 -dl: 56 times
Themes Merah Putih v7 -dl: 55 times
Similtude Black Theme -dl: 52 times
Similitude White Theme -dl: 51 times
PHP Editor -dl: 50 times
Most Read Articles Panel v7 -dl: 49 times
Virus Threats Panel v6 -dl: 48 times
Extended Online User Panel v... -dl: 48 times