Reputation: 4360
All my attempts to Google "host wordpress on subdirectory" seem to be about moving the Wordpress installation to a subdirectory while still serving it from /
. I want to serve it at /blog/
.
I have one docker image running Nginx and another serving Wordpress via php-fpm. I updated siteurl
in the wp_options table to be http://example.com/blog and finally got the index page to show up, but all the related assets give a 403 error. I though it might have to do with a rewrite directive in my Nginx conf, so I tried removing rewrite ^/blog/(.*) /$1 break;
, but that then caused /blog
to return 404.
Here's the relevant portion of my Nginx conf:
location /blog/ {
resolver ${RESOLVER_IP};
set $wordpress_host "${WORDPRESS_SERVICE_HOST}";
rewrite ^/blog/(.*) /$1 break;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME /srv$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $document_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT /srv;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param HTTP_X_REAL_IP $remote_addr;
fastcgi_param HTTP_X_FORWARDED_FOR $proxy_add_x_forwarded_for;
fastcgi_param HTTP_X_FORWARDED_HOST $http_host;
fastcgi_param HTTP_X_FORWARDED_PROTO $real_scheme;
fastcgi_param HTTP_HOST $http_host;
# requests gzipped content from php. gunzip is used for clients that
# can't accept gzip.
fastcgi_param HTTP_ACCEPT_ENCODING "gzip";
fastcgi_param HTTP_X_PREFERRED_TYPE $preferred_type;
fastcgi_read_timeout 60;
fastcgi_next_upstream error timeout http_500 http_503;
fastcgi_buffers 16 64k;
# specifies buffer used for HTTP headers, doesn't need to be large
fastcgi_buffer_size 2k;
fastcgi_temp_file_write_size 64k;
fastcgi_pass $wordpress_host:80;
fastcgi_index index.php;
#echo '';
add_header X-document_root $document_root;
add_header X-fastcgi_script_name $fastcgi_script_name;
add_header X-request_uri $request_uri;
add_header X-document_uri $document_uri;
}
Upvotes: 1
Views: 251
Reputation: 8329
Wordpress should be working if you uploaded it fully, and changed siteurl AND home records as you need them.
Upvotes: 1
Reputation: 7617
If you created a Directory called
blog
under your Web_Root and uploaded the entire Wordpress to this location plus make some minor changes to the thewp_options
table in Your Database; You may not need to touch any Configuration Files at all. Navigating to http://domain.com/blog/ would serve the expected same output... (which are Wordpress Pages).
Upvotes: 2