Saturday, 16 February 2019

rewrite url dengan htaccess

Category : PHP Script
kali ini saya akan mencoba untuk memebrikan tutorial mengenai rewrite url,

yang di butuhkan server apache dengan module mod_rewritenya sudah nya

tujuan dari rewrite url adalah supaya mudah untuk di kenal oleh search engine. file untuk rewrite bernama .htaccess

saya berikan contoh kasus untuk rewrite

misalnya saya punya link seperti ini dengan judul artikel "mencari kutu siang malam"

dalam url di atas sangat sulit untuk di baca oleh google, coba lihat link di bawah ini

lebih rapi bukan, dari url saja kita bisa tau judulnya

cara buat .htaccessnya kira2 seperti ini

RewriteEngine on
RewriteRule ^lihat_detail/([0-9]+)/([0-9a-zA-Z_]+)/?$ baca_blog.php?id=$1   [L,QSA]


RewriteEngine on -> untuk mengaktifkan engine

RewriteRule ^lihat_detail/([0-9]+)/([0-9a-zA-Z_]+)/?$ baca_blog.php?id=$1   [L,QSA]  -> nah di sini kita membutuhkan pengetahuan mengenai regex. intinya lihat pada delimiter / , di sana ada 3 bagian
  1. lihat_detail -> hanya sebagai label saja, biasanya buat kasih tau dia ke file yang mana, karena dalam satu aplikasi kita bakal banyak membutuhkan banyak tipe
  2. ([0-9]+) -> ini buat id blog tadi (id=2)
  3. ([0-9a-zA-Z_]+) -> ini buat judul blog (judul = mencari kutu siang malam)
cukup mudah bukan?

oh ya ada syaratnya klo mo mengunakan rewrite ini, yaitu harus mengunakan absolute path, contohnya gini jangan pake ini :
<img src="../../img/bola.gif">
<a href='../../tes.php' >
tapi gunakan
<img src="">
<a href=''>

kenapa di perlukan absolute path?
misalanya anda telah mengunakan url

bagi program kita memliki folder yang bernama mencari_kutu_siang_malam padahal itu kan hanya folder semu. bayangkan bila kita mengunakan ../../gambar.

Like this articles? share it with Share With FacebookFacebook
<< Back
0 Comment | 6346 hits | Posted by Callrid at 2008-05-29 21:08:38

Related Read

Add Comment
Name :
Web :
Comment :

Code :

Other Source
A Practical Guide On Complete Multivitamins
Many of us have a hard time deciding what the best multivitamin is for us. This is completely confusing and difficult especially when there are so many bottles to scan in the various aisles of the...

High Blood Pressure
The nutritional benefits of low-fat dairy products are well known for ages. The latest studies show that the ingredients of dairy products - some combination of milk proteins are effective and...

Welcome To - Quality Luxury Replica Vacheron Constantin Watches At Affordable Price
When entering our online store at, you are given an unique opportunity to choose among a wide selection of famous Replica Watches and Replica handbags such as Replica Vacheron...

Ebook Marketing Tips
A great way to have a product to sell on the Internet is an e-book which almost anyone can create. There is no longer any need for delaying with the simple process detailed below. If you are afraid...

Tactical Asset Marketing
Asset Management Different Asset Allocation Strategies Asset marketing is the process of dividing a portfolio into major asset categories such as cash, stocks, real estate, or...

Shout Box
2016-11-24 08:56:05 
Pembicara Internet M
Website yagn bagus
2016-11-24 08:40:45 
Produsen Mukena
Good Website
2016-04-05 20:44:45 
Belanja Alat ukur
Belanja Alat ukur dan Thermal Camera Hanya di
2016-04-04 07:10:03 
hit obat nyamuk
hit obat nyamuk
2016-03-31 15:26:29 
vay dam Lury 2016
We stumbled over here from a different web address and thought I might as well check things out. I like what I see so i am just following you. Look forward to finding out about your web page yet again.

Site Partners

Search Articles

Web Statistic
No Visitor :
Today Visitor :
Online Visitor :
what is my ip address? Page Rank Checker

< Feb 2019 >

Increase Page Rank

Last Modified 08-November-2011, 23:21:04 pm Created 2006-2012 by Anton Ongsono
All rights reserved