RewriteEngine On RewriteCond %{REQUEST_URI} !%1\.php RewriteCond %{QUERY_STRING} topic=(.*) RewriteRule ^index\.php$ %1.php [QSA,L]