Skip to content

Instantly share code, notes, and snippets.

@matthewpizza
Created November 29, 2016 16:05
Show Gist options
  • Save matthewpizza/97aaa0fde50d434e429e06d262b7f14f to your computer and use it in GitHub Desktop.
Save matthewpizza/97aaa0fde50d434e429e06d262b7f14f to your computer and use it in GitHub Desktop.
Rewrite requests to WordPress in a subdirectory
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) wp/$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ wp/$2 [L]
RewriteRule . index.php [L]
</IfModule>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment