Bedrock under a sub-directory and access through a reverse proxy setup

Hi,

First of all a big thanks to the bedrock team. I use bedrock boilerplage for all my WP projects and no issues so far. This boilerplate solved several of our past issues.

Now, I need to setup bedrock in a sub-directory and get accessed through a reverse proxy setup.
Please see below the setup as per my REQUIREMENTS:

Main Domain
https://www.domain.com/

Blog URL
https://www.domain.com/blog/ -> Reverse Proxy to the below WP installation

Reverse proxy setup in apache server.
ProxyPass /blog/ https://blog.domain.com/blog/
ProxyPassReverse /blog/ https://blog.domain.com/blog/

Wordpress Installation (Bedrock)
https://blog.domain.com/blog/

Wordpress Project Root
/path/to/blog.domain.com/wp

Document root in Nginx
root /path/to/blog.dmain.com/wp/web;

Physical directory (blog) under web
/path/to/blog.dmain.com/wp/web/blog;

Created the below symlinks in the above folder (blog)
ln -s …/wp/ wp
ln -s …/app/ app
ln -s …/wp-config.php wp-config.php
ln -s …/index.php index.php

.env file
WP_HOME=https://blog.domain.com/blog
WP_SITEURL=https://blog.domain.com/blog/wp/

wp_options table
siteurl -> https://blog.domain.com/blog/wp
home -> https://blog.domain.com/blog/wp

With the above setup, the below URLs work fine.
https://www.domain.com/blog/
Blog homepage works fine and loads all the theme assets from https://blog.domain.com/blog/

https://www.domain.com/blog/wp-json/wp/v2/posts
REST API works fine

https://blog.domain.com/blog/wp/wp-admin/
Able to login in the WP admin and create/edit pages and posts without any issues.

However, other than the blog home page, rest of the pages and posts do not work and getting redirected as shown below, when accessed through the main domain (www.domain.com)

https://www.domain.com/blog/page-x -> https://www.domain.com/blogpage-x
https://www.domain.com/blog/hello-world -> https://www.domain.com/bloghello-world

Note the leading slash of the page-slug/permalink is removed and redirected as /blogpage-x or /bloghello-world and resulting 404 error in the main domain.

I have deactivated yoast seo plugin.

Not sure what I am missing. Should I change any of my bedrock configs?

Please help. Thanks in advance,

Regards,
Srini

By disabling canonical redirection, the issue solved
remove_action(‘template_redirect’, ‘redirect_canonical’);

Thanks to Mahesh Waghmare

This topic was automatically closed after 42 days. New replies are no longer allowed.