Membuat alamat link URL menjadi cantik
Rewrite URL adalah salah satu dari tenik SEO.
Berikut contoh simple pembuatan URL cantik menggunakan .htaccess
simpan file pada root folder project Anda dengan nama .htaccess
RewriteEngine On RewriteCond %{REQUEST_FILENAME} -f [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^(.+) - [PT,L] RewriteRule ^(.*)$ index.php?do=$1 [QSA,L]
lalu pada file index.php Anda, mainkan aturan URL-nya.
contoh isi file index.php:
<?php $do = explode ("/", $_REQUEST['do']); $opsi = $do[0]; define('PUB_DIR', dirname (__FILE__) . '/' .); switch($opsi) { case 'home': require_once (PUB_DIR . 'home.php'); break; case 'content': require_once (PUB_DIR . 'web_content.php'); break; case 'subcontent': require_once (PUB_DIR . 'web_content_sub.php'); break; case 'news': require_once (PUB_DIR . 'news.php'); break; case 'news-detail': require_once (PUB_DIR . 'news-detail.php'); break; case 'articles': require_once (PUB_DIR . 'articles.php'); break; case 'article-detail': require_once (PUB_DIR . 'article-detail.php'); break; case 'event': require_once (PUB_DIR . 'event.php'); break; case 'event-detail': require_once (PUB_DIR . 'event-detail.php'); break; case 'calendar': require_once (PUB_DIR . 'calendar.php'); break; case 'testimonial': require_once (PUB_DIR . 'testimonial.php'); break; case 'testimonial-sign': require_once (PUB_DIR . 'guestbook_sign.php'); break; case 'product': require_once (PUB_DIR . 'product.php'); break; case 'product_search': require_once (PUB_DIR . 'product_search.php'); break; case 'contact': require_once (PUB_DIR . 'contact_us.php'); break; case 'search': require_once (PUB_DIR . 'search.php'); break; case 'download': require_once (PUB_DIR . 'download.php'); break; case 'faq': require_once (PUB_DIR . 'faq.php'); break; case 'sitemap': require_once (PUB_DIR . 'sitemap.php'); break; default: require_once (PUB_DIR . 'home.php'); }
Semoga membantu


6 Comments on “Membuat alamat link URL menjadi cantik”
thanks atas tip htaccess nya mas/mbak. mau coba2 ah
Like or Dislike: