← Files

.htaccess Redirects and HTTPS

Common Apache rewrite rules.

RewriteEngine On

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

# Remove www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301]

# Single page redirect
Redirect 301 /old-page /new-page

# Custom 404
ErrorDocument 404 /404.html