
Assalamu’alaikum
Warahmatullah Wabarakatuh
Bagi
temen-temen semua khususnya yang hoby coding dengan php mungkin dah nggak
asing lagi dengan kata "localhost". Yup... localhost merupakan domain default bawaan
webserver. Jika teman-teman selesai menginstal webserver (misal: xampp, wamp,
appserv, easyphp, dsb ) kemudian ingin mengetahui hasil instalan web server di
komputer kita berhasil atau nggak, pasti yang pertama kali yaitu mengisi
address bar browser dengan "localhost". Nah pernahkah anda punya
keinginan untuk mengubah dengan nama lain biar seolah-olah kita benar-benar
mengakses web dengan domain yang
telah kita beli di jasa penyedia hosting?? Mungkin banyak
orang sudah mengetahui trik ini, tapi saya rasa banyak juga yang belum tahu.
Trik ini saya dapat dari tempat kerjaku yaitu menambahkan
host di local server atau di localhost kita. Jadi misal kita ingin aplikasi web
yang telah di buat di localhost ketika mengaksesnya lewat browser bukan lagi http://localhost/ tetapi http://namadomain.com/ maka kita perlu
menambahkan host ke server lokal di komputer kita. Dengan kata lain kita ingin
membuat nama alias dari localhost.
Oke, kita
mulai saja.
Pertama buka
Windows Explorer, kemudian akses alamat ini :
C:\WINDOWS\system32\drivers\etc.
Setelah dibuka maka akan menemukan beberapa file antara lain : host, lmhost,
networks, protocol, dan services.
Edit file host
pakai notepad++? atau file editor lain. Setelah dibuka akan muncul text default
:
# Copyright (c) 1993-1999 Microsoft
Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhost
Setelah file tersebut dibuka tambahkan baris di bawah
tulisan "127.0.0.1 localhost" sesuai dengan nama domain yang
dikehendaki misal domaingue.com.
Jadi file tersebut setelah ditambahkan akan menjadi seperti ini :
# Copyright (c) 1993-1999 Microsoft
Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhost
127.0.0.1 domaingue.com
127.0.0.1 domaingue.com
Setelah itu simpan atau Ctrl+S. Kemudian buka browser dan
ketikkan domaingue.com maka
akan diarahkan ke localhost kita :D.
Catatan : Setau saya tips ini berlaku hanya di windows,
untuk inux triknya sedikit berbeda, tapi masih bermain table name server, pada
file host juga.
Terima Kasih. Semoga bermanfaat.