ErrorDocument 403 {BASE_DIR}error_document.php?code=403
ErrorDocument 404 {BASE_DIR}error_document.php?code=404
ErrorDocument 410 {BASE_DIR}error_document.php?code=410
ErrorDocument 500 "Internal Server Error"

Options -Indexes

# URL-rewriting
<IfModule mod_rewrite.c>
  Options +FollowSymLinks
  RewriteEngine on
  
  # Tell PHP that the mod_rewrite module is enabled
  SetEnv HTTP_MOD_REWRITE On
  
  # Web path to catalog root
  RewriteBase {BASE_DIR}
  
  # Non-www to www
  #RewriteCond %{HTTP_HOST} !^www\.
  #RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
  
  # No logic for physical files
  RewriteCond %{REQUEST_FILENAME} -d [OR]
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -l
  RewriteRule ^ - [L]
  
  # SEO translation
  RewriteRule ^(?:[a-z]{2}/)?.*-c-([0-9]+)/?$ category.php?category_id=$1&%{QUERY_STRING} [L]
  RewriteRule ^(?:[a-z]{2}/)?.*-m-([0-9]+)/?$ manufacturer.php?manufacturer_id=$1&%{QUERY_STRING} [L]
  RewriteRule ^(?:[a-z]{2}/)?.*-i-([0-9]+)$ information.php?page_id=$1&%{QUERY_STRING} [L]
  RewriteRule ^(?:[a-z]{2}/)?.*-s-([0-9]+)$ customer_service.php?page_id=$1&%{QUERY_STRING} [L]
  RewriteRule ^(?:[a-z]{2}/)?.*-p-([0-9]+)$ product.php?product_id=$1&%{QUERY_STRING} [L]
  RewriteRule ^(?:[a-z]{2}/)?search/(.*)?$ search.php?query=$1&%{QUERY_STRING} [L]
  RewriteRule ^(?:[a-z]{2}/)?(.*) $1?%{QUERY_STRING} [L]
</IfModule>

# Deny access to content
<FilesMatch "\.(htaccess|htpasswd|inc.php)$">
  Order Allow,Deny
  Deny from all
</FilesMatch>

# Cacheable external content
<IfModule mod_headers.c>
  <FilesMatch "\.(css|gif|ico|jpg|jpeg|js|pdf|png|ttf)$">
    Header set Cache-Control "max-age=864000, public, must-revalidate"
    Header unset Last-Modified
  </FilesMatch>
</IfModule>

# GZip compress external content
<IfModule mod_deflate.c>
  <FilesMatch "\.(css|js)$">
    SetOutputFilter DEFLATE
  </FilesMatch>
</IfModule>