Page 1 of 1

How to convert dynamic URLs to static using .htaccess

Posted: Sun Jan 24, 2010 4:35 am
by Neo
Static URLs are said to improve search engine visibility, etc... When we have few parameters on the URL, this is possible through .htaccess.

Original URL
Ex: https://robot.lk/viewtopic.php?f=41&t=1149

Rewriting Friendly URL
Ex: https://robot.lk/41/1149

.htaccess Code

Code: Select all

//First Parameer
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ viewforum.php?f=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ viewforum.php?f=$1

//Second Parameter
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)$ viewforum.php?f=$1&t=$2
RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)/$ viewforum.php?f=$1&t=$2