To replace a domain name only on certain file types using htaccess, you can use this snippet

RewriteEngine On turns on the Apache mod_rewrite module.

RewriteBase / sets the base URL for rewriting.
RewriteCond %{REQUEST_URI} \.(html|php)$ [NC] matches only files with the extensions ".html" or ".php".
RewriteCond %{HTTP_HOST} ^old-domain\.com$ [NC] matches only requests for the old domain name.
RewriteRule ^(.*)$ http://new-domain.com/$1 [R=301,L] redirects all requests for files with the specified extensions to the new domain.

Note that the R=301 flag is used to indicate a permanent redirect, and the L flag is used to stop further rewriting. You should also replace "old-domain.com" and "new-domain.com" with the appropriate domain names for your site.