Skip to content

Instantly share code, notes, and snippets.

@kikmedia
Created August 9, 2023 11:01
Show Gist options
  • Save kikmedia/a4cf8b11d78e9e34133b1725b97cc38f to your computer and use it in GitHub Desktop.
Save kikmedia/a4cf8b11d78e9e34133b1725b97cc38f to your computer and use it in GitHub Desktop.
rewrite snippets apache
## force www domain
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,NC,L]
## rewrite everything which is not the correct domain
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment