Add a new htaccess file in your /fun/
directory (which I assume is the document root of the fun.example.com
subdomain) with these rules:
Options -Multiviews
RewriteEngine On
RewriteCond %{HTTP_HOST} ^fun\.example\.com$ [NC]
RewriteCond %{THE_REQUEST} \ /+([^/]+)\.php\?id=([^&\ ]+)
RewriteRule ^ /%1/%2? [L,R]
RewriteCond %{HTTP_HOST} ^fun\.example\.com$ [NC]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} !-d
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f
RewriteRule ^([^/]+)/(.*)$ /$1.php?id=$2 [L]