Ashley Cameron Design

Ashley Cameron Design

Shop the Creative Design Market

Good morning

Speed Up & Help Secure WordPress with htaccess

SnippetsWordPress

About a 1 minute read

"I am always doing what I cannot do yet, in order to learn how to do it."

Vincent Van Gogh


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Protect the htaccess file
<Files .htaccess>
    Order Allow,Deny
    Deny from all
</Files>

# Protect the htaccess file
<Files wp-config.php>
    Order Allow,Deny
    Deny from all
</Files>

# Disable directory browsing
Options All -Indexes

# Enable the following of symlinks
Options +FollowSymLinks

<IfModule mod_headers.c>
    # No ETags, No Pragma
    Header unset Pragma
    Header unset ETag
    # Make sure proxies deliver correct content
    Header append Vary User-Agent env=!dont-vary
    # Ensure proxies deliver compressed content correctly
    Header append Vary Accept-Encoding
</IfModule>

# BEGIN WordPress
RewriteEngine on
#
# Unless you have set a different RewriteBase preceding this
# point, you may delete or comment-out the following
# RewriteBase directive:
RewriteBase /
#
# if this request is for "/" or has already been rewritten to WP
RewriteCond $1 ^(index.php)?$ [OR]
# or if request is for image, css, or js file
RewriteCond $1 .(gif|jpg|css|js|ico)$ [NC,OR]
# or if URL resolves to existing file
RewriteCond %{REQUEST_FILENAME} -f [OR]
# or if URL resolves to existing directory
RewriteCond %{REQUEST_FILENAME} -d
# then skip the rewrite to WP
RewriteRule ^(.*)$ - [S=1]
# else rewrite the request to WP
RewriteRule . /index.php [L]
#
# END wordpress