Lets Play URL Rewrite
23
Jul
2007
Jika anda membuat program web anda sendiri tentu tidak asing dengan penggunaan parameter seperti berikut ini:
http://konconebudi.com?kategori=7&id=5 (parameter yang digunakan adalah kategori dan id)
Beberapa master SEO menyarankan untuk mengubah tatanan URL tsb, sehingga diusahakan agar menjadi misalnya:
http://konconebudi.com/kategori/produk-5.html
hal ini dikarenakan URL yang tertata rapi akan mudah dibaca oleh mesin pencari.
Ok, kita mulai aja ya… Untuk memulainya tanyakan dulu kepada webmaster anda apakah Server Anda mensupport URL rewrite? Jika tidak, urungkan niat Anda daripada muncul Error 500 pada website Anda. Jika mereka support, Lanjuuuut…
1. Definisikan dulu URL yang akan anda ubah, disini saya kan mengubah
http://konconebudi.com/tes.php?id=5 agar menjadi http://konconebudi.com/halo/5.html
2. Buatlah sebuah file .htaccess
3. Isi file .htaccess anda dengan baris-baris script berikut:
RewriteEngine On
RewriteRule ^halo/([0-9]*)\.html$ /tes.php?id=$1 [L]
4. buat file tes.php, untuk mencobanya create file php berikut ini:
echo "id yang dimasukkan adalah:$_GET[id]"; ?>
5. Terus Coba cek misalnya
http://konconebudi.com/halo/5.html
apakah muncul
id yang dimasukkan adalah:5
jika iya, berarti URL rewrite anda sudah sukses…
jadi untuk selanjutnya untuk mengakses tes.php?id=1233 anda juga bisa mengakses link berikut halo/1233.html
Tambahan:
Untuk 2 parameter tambahakan pada .htaccess anda
RewriteRule ^halo/.*-C([0-9]+)/.*-P([0-9]+)\.html$
/tes.php?kategori=$1&id=$2 [L]
Sehingga URL tes.php?kategori=12&id=333 akan diterjemahkan menjadi halo/kategori-C12/produk-P333.html
Lets Play URL Rewrite
If you make your own web programs would be familiar with the use of parameters such as the following:
http://konconebudi.com?kategori=7&id=5 (parameters used are the category and id)
Some SEO master suggested to change the order of the URL they will be, so it sought to become for example:
http://konconebudi.com/kategori/produk-5.html
this is because the URL is well-organized, easy to read by search engines.
Ok, we start aja ya ... To get started you first check with the webmaster if your server supports URL rewrite? If not, revert your intentions than Error 500 appears on your website. If they support, Lanjuuuut ...
1. Define the first URL that you want to change, here's my change
http://konconebudi.com/tes.php?id=5 to be http://konconebudi.com/halo/5.html
2. Create a file. Htaccess
3. The contents of the file. Htaccess you with the following script lines:
RewriteEngine On
Hello RewriteRule ^ / ([0-9] *) . Html $ / tes.php? Id = $ 1 [L]
4. create a file tes.php, to try create the following php file:
5. Continue to Try to check for example
http://konconebudi.com/halo/5.html
does appear
id entered is: 5
if so, then rewrite the URL you've successfully ...
so for the next to access tes.php? id = 1233 You can also access the following link halo/1233.html
Additional:
For 2 parameters tambahakan on. Htaccess you
RewriteRule ^ hello / .*- C ([0-9 ]+)/.*- P ([0-9] +) . Html $
/ Tes.php? Category = $ 1 & id = $ 2 [L]
So the URL tes.php? Category = 12 & id = 333 will be translated into halo/kategori-C12/produk-P333.html
Yang laennya:
,belajar url rewrite,rewrite url dengan 2 parameter dengan htaccess,htaccess rewrite dengan 2 parameter
5 Responses to Lets Play URL Rewrite
Duit Gratisan
June 12th, 2008 at 9:08 am
Wah lumayan buat tambah wawasan..
Buat URL Cantik « Mxin’s Weblog
September 12th, 2008 at 12:10 am
[...] http://blog.jefendi.web.id/2008/02/03/paksa-server-memakai-php-v-4/ http://www.konconebudi.com/uncategorized/lets-play-url-rewrite.html [...]
Rius
January 15th, 2009 at 6:46 pm
halo mas,
bagus ni tutorial, tp saya ada kendala mas,
saya kan pake akses urlnya pake menu contoh:
Jual
gimana tulis url tersebut mas di menunya…
thanks
Adm
January 15th, 2009 at 10:27 pm
@Rius
bingung maksudnya gimana mas?
Picas
January 28th, 2010 at 4:59 am
Well Done..I have try using your example..It Work like Charm..
Thank you very much.!!!!
You’re Rock !!!!