RewriteEngine On

# Enable the mod_expires module
ExpiresActive On

# Cache resources with specified file extensions
ExpiresByType image/jpeg "access plus 1 year"
ExpiresByType image/png "access plus 1 year"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType text/css "access plus 1 month"

# Set default expiration for other resources
ExpiresDefault "access plus 1 week"

# Redirect to html file
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.+)$ $1.html [L]

# Redirect to php file
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.+)$ $1.php [L]

# Redirect 404 errors to a specific site
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ 404.html [L,R=301]