RewriteEngine On
RewriteCond %{HTTP_HOST} ^site.com [NC]
RewriteRule ^(.*)$ http://www.site.com/$1 [L,R=301,NC]
RewriteRule ^index\.html$ / [R=301,L]
RewriteRule ^(.*)/index\.html$ /$1/ [R=301,L]
RewriteCond %{QUERY_STRING} ^p=1226+$ [NC]
RewriteRule ^(.*)$ http://www.site.com/$1? [R=301,L]
RewriteBase /
# Defines 404 error pages content:
ErrorDocument 404 http://www.site.com/not-found.html
# for all invalid links (non existing files):
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* - [L,R=404]