Skip to content

Instantly share code, notes, and snippets.

@mhemrg
Last active January 22, 2021 15:35
Show Gist options
  • Save mhemrg/024b9b46973674921a1e3304249fe2d1 to your computer and use it in GitHub Desktop.
Save mhemrg/024b9b46973674921a1e3304249fe2d1 to your computer and use it in GitHub Desktop.
WordPress in a subdirectory
  1. Go to Settings -> General
  2. Change Wordpress URL and Site URL to https://domain.ir/blog
  3. Create the liara_nginx.conf in a static app with the following content and deploy it.
  4. Update wp-config.php.

You're good to go.

resolver 127.0.0.11 ipv6=off valid=5s;
location / {
index index.html index.htm;
}
location ~/blog(.*)$ {
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto https;
set $wpblog app-id:80;
proxy_pass http://$wpblog$1;
}
<?php
// Put the following 2 lines to the wp-config.php file before the "That's all, stop editing! Happy publishing." comment
$_SERVER['REQUEST_URI'] = str_replace("/wp-admin", "/blog/wp-admin", $_SERVER['REQUEST_URI']);
define( 'CONCATENATE_SCRIPTS', false );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment