# Caltech Tools — forced canonical SEO redirects
# Apply in aaPanel → Website → Config (or include this file).
# Canonical origin: https://pinebrookapartmentsofbutler.com

# HTTP → HTTPS (all hosts)
server {
    listen 80;
    listen [::]:80;
    server_name pinebrookapartmentsofbutler.com www.pinebrookapartmentsofbutler.com;
    return 301 https://pinebrookapartmentsofbutler.com$request_uri;
}

# Non-canonical HTTPS host → canonical host
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name www.pinebrookapartmentsofbutler.com;
    # ssl_certificate / ssl_certificate_key — keep aaPanel-managed certs here
    return 301 https://pinebrookapartmentsofbutler.com$request_uri;
}

# Canonical host — real 404 (never soft-404)
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name pinebrookapartmentsofbutler.com;
    # ssl_certificate / ssl_certificate_key — keep aaPanel-managed certs here
    root /www/wwwroot/pinebrookapartmentsofbutler.com;
    index index.html index.htm;

    error_page 404 /404.html;
    location = /404.html {
        internal;
        add_header X-Robots-Tag "noindex, nofollow" always;
    }

    # Optional URL map (edit url-map.json then convert to rewrites):
    # rewrite ^/old-path$ /new-path permanent;

    location / {
        try_files $uri $uri/ $uri.html $uri/index.html =404;
    }
}
