# Enable mod_rewrite
RewriteEngine On

# Redirect www to non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

# Redirect HTTP to HTTPS
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

# Custom error pages
ErrorDocument 404 /error.html


# Compress text files
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript
</IfModule>

# Security headers
<IfModule mod_headers.c>
    Header set X-Content-Type-Options "nosniff"
    Header set X-XSS-Protection "1; mode=block"
    Header set X-Frame-Options "DENY"
    Header set Content-Security-Policy "default-src 'self'"
</IfModule>

# Prevent directory listing
Options -Indexes

# Redirect using a query parameter
RewriteCond %{QUERY_STRING} ^url=(https?://.*)$
RewriteRule ^redirect$ %1 [R=301,L]

# 301 Redirects
# Specific 301 Redirect: oldpage.html to newpage.html
Redirect 301 /order https://16875k3k-zrhgq59fswan0bu4k.hop.clickbank.net


