Put this code in your DOCUMENT_ROOT/.htaccess
file:
RewriteEngine On
RewriteBase /
RewriteCond %{THE_REQUEST} \s/+product\.php\?id=([^\s&]+) [NC]
RewriteRule ^ product/%1? [R=301,L]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^product/([^/.]+)/?$ product.php?id=$1 [L,QSA]
RewriteRule ^([A-Za-z\s0-9-]+)/?$ /product.php?id=$1 [L,QSA]
For problems with css/js/images use absolute path in your css, js, images files rather than a relative one. Which means you have to make sure path of these files start either with http://
or a slash /
.
You can try adding this in your page's HTML header: <base href="/" />