RewriteEngine on

Options +FollowSymLinks

RewriteCond %{REQUEST_URI} !(main\.php)
RewriteCond %{QUERY_STRING} !(direct)
RewriteRule (.*) main.php?page=$1 [PT]

RewriteCond %{QUERY_STRING} (direct)
RewriteRule (.*) $1 [PT]