Drupal .htaccess

Redirect the HTTPS

  # Redirect HTTP to HTTPS
  RewriteCond %{HTTPS} off
  RewriteCond %{HTTP:X-Forwarded-Proto} !https
  RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Redirect to canonical URL

  # Redirect to canonical domain
  RewriteCond %{HTTP_HOST} .
  RewriteCond %{HTTP_HOST} !^www\.example\.coop$ [NC]
  RewriteRule ^ https://www.example.coop%{REQUEST_URI} [L,R=301]

Deny autodiscovery requests

  # 404 Outlook autodiscover requests
  RewriteCond %{REQUEST_URI} /autodiscover/autodiscover.xml [NC]
  RewriteRule ^ - [L,R=404]

Links

  • [[2025-W21]]