# GitHub Code Viewer Plugin - Security Rules
# Prevent directory browsing
Options -Indexes
# Deny access to all files by default
Order Deny,Allow
Deny from all
# Allow access to specific file types only
Order Allow,Deny
Allow from all
# Specifically allow access to the main plugin file
Order Allow,Deny
Allow from all
# Protect sensitive files
Order Allow,Deny
Deny from all
# Disable PHP execution in subdirectories (except the root plugin file)
Order Deny,Allow
Deny from all
# Prevent script injection
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR]
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR]
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2})
RewriteRule ^(.*)$ - [F,L]
# Disable XML-RPC if not needed
Order Deny,Allow
Deny from all
# Add security headers
Header set X-Content-Type-Options "nosniff"
Header set X-Frame-Options "SAMEORIGIN"
Header set X-XSS-Protection "1; mode=block"
Header set Referrer-Policy "strict-origin-when-cross-origin"
# Hotlinking protection disabled - not needed for WordPress plugins
# WordPress plugins need their assets accessible to the host site
#
# RewriteEngine on
# RewriteCond %{HTTP_REFERER} !^$
# RewriteCond %{HTTP_REFERER} !^https?://(www\.)?%{HTTP_HOST} [NC]
# RewriteRule \.(css|js|png|jpg|jpeg|gif|svg)$ - [F,NC,L]
#
# Compress text files
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/json
# Set proper MIME types
AddType text/css .css
AddType application/javascript .js
AddType application/json .json
# Cache control for static assets
ExpiresActive On
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/svg+xml "access plus 1 month"
# Disable server signature
ServerSignature Off
# Prevent access to hidden files
Order Allow,Deny
Deny from all
# Block access to backup and source files
Order Allow,Deny
Deny from all