Wednesday, May 02, 2007

mod_rewrite and REQUEST_URI

Yesterday I did a forum move , a SMF forum. We had to move the forum URL from http://www.domain.com/forum to http://www.domain.com along with moving the servers, but still not losing the links spidered by Google. So things had to be achieved by mod_rewrite and the below rewrite rule helped.

RewriteEngine on
RewriteCond %{REQUEST_URI} ^/forum/(.*)$ [NC]
RewriteRule ^forum/(.*)$ /$1 [R=301,L]

What this will do is redirect

http://www.domain.com/forum/index.php?PHPSESSID=0aj813j131434061699fb61eef295f
to
http://www.domain.com/index.php?PHPSESSID=0aj813j131434061699fb61eef295f

Praise the mod_rewrite authors !!!

No comments: