DirectoryIndex index.php index.html index.htm
Options -Indexes
AddType application/manifest+json .webmanifest

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /

  # Only act on requests for jpindustries.com. When this site sits in the top of public_html,
  # cPanel addon domains live in sub-folders underneath it and would otherwise inherit these rules.
  RewriteCond %{HTTP_HOST} !^(www\.)?jpindustries\.(com|test)(:\d+)?$ [NC]
  RewriteCond %{HTTP_HOST} !^(localhost|127\.0\.0\.1)(:\d+)?$ [NC]
  RewriteRule ^ - [L]

  # The https://www. redirect for jpindustries.com lives in the top-level public_html/.htaccess
  # (see root.htaccess). If this folder is ever served directly as its own document root, remove
  # the # from the next 3 lines instead.
  # RewriteCond %{HTTPS} off [OR]
  # RewriteCond %{HTTP_HOST} !^www\. [NC]
  # RewriteRule ^(.*?)/?$ https://www.jpindustries.com/$1 [L,R=301]

  # Addresses that expose the folder name (/ws_jpindustries/...) → the clean address
  RewriteCond %{THE_REQUEST} ^\S+\s/+ws_jpindustries(?:\.com)?(/[^?\s]*)?[?\s] [NC]
  RewriteRule ^ https://www.jpindustries.com%1 [R=301,L,NE]

  # Block any leftover WordPress probe URLs
  RewriteRule ^(wp-admin|wp-includes|wp-content|wp-login\.php|wp-json|xmlrpc\.php) - [R=410,L]

  # Other websites' folders in public_html (cPanel addon domains) are not part of this site.
  RewriteCond $1 !^(api|app|images|\.well-known|cgi-bin)$ [NC]
  RewriteCond %{DOCUMENT_ROOT}/$1 -d
  RewriteRule ^([^/]+)(?:/.*)?$ - [R=404,L]

  # Only the API entry point runs over the web; helper scripts (cron, secrets, …) are command-line only.
  RewriteRule ^api/(?!index\.php$)[^/]+\.php$ - [R=404,L]

  # JSON API: /api/site, /api/page, ... → api/index.php
  RewriteRule ^api/([a-z]+(?:/[a-z]+)?)/?$ api/index.php?route=$1 [QSA,L]

  # Real files and folders are served as-is (JS, CSS, images)
  RewriteCond %{REQUEST_FILENAME} -f [OR]
  RewriteCond %{REQUEST_FILENAME} -d
  RewriteRule ^ - [L]

  # Everything else → React front controller
  RewriteRule ^ index.php [QSA,L]
</IfModule>

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresByType image/jpeg "access plus 30 days"
  ExpiresByType image/png "access plus 30 days"
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"
</IfModule>

<IfModule mod_deflate.c>
  AddOutputFilterByType DEFLATE text/html text/css application/javascript application/json image/svg+xml
</IfModule>
