Skip to content

Instantly share code, notes, and snippets.

@rinatkhaziev
Last active November 15, 2018 06:25
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 rinatkhaziev/4925b71995bb9b9e1953987cb203b5c7 to your computer and use it in GitHub Desktop.
Save rinatkhaziev/4925b71995bb9b9e1953987cb203b5c7 to your computer and use it in GitHub Desktop.
Nginx rewrite rules when WordPress core files are in a subfolder
# Files are physically in `wp` subfolder but we'd like to serve requests /
# Goes inside server { } block
if (!-e $request_filename) {
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$request_uri/ permanent;
# WordPress in a subdirectory rewrite rules
rewrite ^/([_0-9a-zA-Z-]+/)?(wp-.*|xmlrpc.php) /wp/$2 break;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment