« Home

Create Clean URL with htaccess

Need a pretty url in your web, need a great ranking in search engine one way you can do is using htaccess. The work of this file is simple just like redirect in php

this is an htacess file that i use for my cms auracms the indonesian cms :P, the pattern is easy to make the rule

RewriteRule ^newpattern$ oldpattern [QSA,L]

Options +FollowSymlinks
RewriteEngine on

RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [S=84]

RewriteRule ^index.html$ ./ [QSA,L]
RewriteRule ^artikel/(.+)$ ./?pilih=lihat&id=$1 [QSA,L]
RewriteRule ^kirim-artikel.html$ ./?pilih=berita [QSA,L]
RewriteRule ^kategori\-(.+)\-(.+)\-(.+)$ ./?pilih=arsip&mulai=$1&hal=$2&id=$3[QSA,L]
RewriteRule ^cari/(.+)\-(.+)\-(.+)$ ./?pilih=search&mulai=$1&hal=$2&query=$3 [QSA,L]
RewriteRule ^bukutamu.html$ ./?pilih=gb [QSA,L]
RewriteRule ^bukutamu\-(.+)\-(.+).html$ ./?pilih=gb&mulai=$1&hal=$2 [QSA,L]
RewriteRule ^isi-bukutamu.html$ ./?pilih=gb&option=add [QSA,L]
RewriteRule ^kata-mutiara.html$ ./?pilih=kata_mutiara [QSA,L]
RewriteRule ^kata-mutiara\-(.+).html$ ./?pilih=kata_mutiara&page=$1 [QSA,L]
RewriteRule ^kontak_saya.html$ ./?pilih=mail [QSA,L]
RewriteRule ^kirim-ke-teman/(.+)$ ./?pilih=teman&id=$1 [QSA,L]
RewriteRule ^kirim-pesan/(.+)$ ./?pilih=pesan&id=$1&op=komentar [QSA,L]
RewriteRule ^tentang.html$ ./?pilih=hal&id=2 [QSA,L]


one think that you shuld remember is, you server must be support mod_rewrite. If you try it in localhost, open your http.conf in folder apache - conf - http.conf

edit these http.conf.

but how :) relax for dummies like me just click ctrl+f and type rewrite

so you gonna find any file that contain #


#LoadModule rewrite_module modules/mod_rewrite.so

so you must erase that first symbol so it gonna be like

LoadModule rewrite_module modules/mod_rewrite.so


after that restart your apache server , after that pray to god perhaps your localhost can be support mod_rewrite :)

but if your host is online, just ask your administrator is your hosting support mod_rewrite, if it isn't just change your hosting to the other hosting simple right.

Maybe Related

Previous posts

Archives

Subscribe in NewsGator Online Top Lyric Today Top Lyric Today Add to Google Add to My AOL Subscribe in FeedLounge Add to netvibes Add to The Free Dictionary Subscribe in NewsAlloy Subscribe in Bloglines Add to Bitty Browser Add to Plusmo Add TopLyricToday to ODEO Subscribe in podnova Add to Technorati Favorites Blogger Indonesia