Skip to content

Instantly share code, notes, and snippets.

@abelcallejo
Last active May 16, 2020 11:41
Show Gist options
  • Save abelcallejo/dae83a903bd27317429912218291014a to your computer and use it in GitHub Desktop.
Save abelcallejo/dae83a903bd27317429912218291014a to your computer and use it in GitHub Desktop.
Default WordPress .htaccess

Default WordPress .htaccess

Hostname installation

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Sub-directory installation

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /directory/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /directory/index.php [L]
</IfModule>
# END WordPress

Guides

Static resources overrides Wordpress

WordPress handles the request only if the requested resource is not an existing file or directory.

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Wordpress overrides static files

WordPress handles the request if the requested resource is an existing file inside the wp-content/uploads directory.

RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^wp-content/uploads/(.*)$ /index.php [L]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment