Skip to content

Instantly share code, notes, and snippets.

@thegrid22593
Last active May 8, 2018 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thegrid22593/a8a5c1870bf81d500e0f1609e7b9bab1 to your computer and use it in GitHub Desktop.
Save thegrid22593/a8a5c1870bf81d500e0f1609e7b9bab1 to your computer and use it in GitHub Desktop.
#### Forward entire domain
```
RedirectMatch 301 ^(.*)$ http://www.valenciamorganhill.com/
```
#### Forward entire domain alt.
```
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^lyonautumnchase.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.lyonautumnchase.com$
RewriteRule ^(.*)$ http://www.lyoncommunities.com/communities/welcome/autumn-chase [R=301,L]
```
#### Add SVG Support
```
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
```
#### Redirect non-www urls to www
```
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.yoursite\.com
RewriteRule (.*) http://www.yoursite.com/$1 [R=301,L]
```
#### Redirect non-www urls to www
```
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
```
#### Force https://
```
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
```
#### Force https & www at the same time
```
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\.domain\.com$ [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment