Skip to content

Instantly share code, notes, and snippets.

@joekolade
Last active May 12, 2023 09:56
Show Gist options
  • Save joekolade/a0a7f3ed9806c75c74b08beaf7f55d2d to your computer and use it in GitHub Desktop.
Save joekolade/a0a7f3ed9806c75c74b08beaf7f55d2d to your computer and use it in GitHub Desktop.
[htaccess] Htaccess things #server
# redirect non www to www
RewriteCond %{HTTP_HOST} !^(www|dev)\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
# Non SSL to SSL
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
# 301 Redirect only when on a special subdomain/domain
RewriteCond %{HTTP_HOST} ^###subdomain###\.###domain###\.###tld###$ [NC]
RewriteRule ^/###redirect_source###$ https://###subdomain###.###domain###.###tld###/###redirect_target### [L,R=301]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment