RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{QUERY_STRING} (?:^|&)id\=1(?:$|&)
RewriteCond %{QUERY_STRING} (?:^|&)url\=test(?:$|&)
RewriteRule ^profile$ /test? [L,R=301]
RewriteCond %{QUERY_STRING} (?:^|&)id\=1(?:$|&)
RewriteCond %{QUERY_STRING} (?:^|&)url\=(.+)(?:$|&)
RewriteRule ^profile$ /%1? [L,R=301]