Menu
Samaritan's Purse

.HTACCESS

.htaccess, or hypertext access, is a file that allows directory-level configuration changes.

Changes by this file apply to the directory where it is located and all subdirectories. It does not have a file name, only a file extension. The leading dot designates it as a hidden file.

INSTRUCTIONS

  1. Open Notepad
  2. Copy and paste code below
  3. Click File
  4. Click Save As...
  5. After File name:, type .htaccess
  6. After Save as type:, select All Files
  7. Click Save
  8. Upload .htaccess to the root directory of your website

HTTPS

RewriteEngine on

RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
FROM TO
http:// https://

NO-WWW

RewriteEngine on

RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
FROM TO
www.mydomain.com mydomain.com

KEY

RewriteEngine - rewrite engine
RewriteCond - rewrite condition
RewriteRule - rewrite rule

on - on
off - off

%{HTTPS}     - hypertext transfer protocol secure
%{HTTP_HOST} - hypertext transfer protocol host
%{REQUEST_URI} - request uniform resource identifier

^ - start of string
$ - end of string

. - match any     character
? - match previous character zero or one time
* - match previous character zero or more times
+ - match previous character one or more times

\ - escape next character (treat special character as normal character)

() - group

%0 - backreference to rewrite condition
%N - backreference to rewrite condition group (1 <= N <= 9)
$0 - backreference to rewrite rule
$N - backreference to rewrite rule     group (1 <= N <= 9)

[L]     - last
[NC]    - no case (case insensitive)
[R]     - temporary redirect
[R=301] - permanent redirect

INTERNAL

acme.sh

EXTERNAL

Apache .htaccess

Apache Regular Expressions

Apache RewriteCond

Apache RewriteEngine

Apache RewriteRule

Apache RewriteRule Flags