I have a WordPress instance running via http-proxy-middleware, so I can have my WordPress blog under example.com/blog
The problem I'm struggling with is I cannot configure the .htaccess
file properly.
Here's my config:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
By default, WordPress generates all links without the trailing slash.
I can access the following:
example.com/blog/wp-login.php
example.com/blog/wp-admin/
example.com/blog/wp-admin/index.php
But when I go to example.com/blog/wp-admin
(no trailing slash) the redirection fails.
Same happens when I manually add the trailing slash to a post link:
example.com/blog/testing
works
example.com/blog/testing/
fails
I wonder if I should focus on the http-proxy-middleware
configuration or could it be that my .htaccess
file is configured incorrectly?
/blog/hello-world/wp-admin/
- What's the/hello-world
part? This is missing from your later URLs. There's nothing in.htaccess
to handle the trailing slash on WP URLs (nor should there be). All the.htaccess
code does is route all requests (whether they contain a trailing slash or not) to the WordPress front-controller, ie.index.php
. WP would then handle the routing. Is the request with a trailing slash reaching WP?/blog/
then you should not be able to access WP Admin at/blog/hello-world/wp-admin
. Note that we are not a support route for the http-proxy-middleware package/hello-world
part by mistake. Of course it should not be there. I updated the origin post. Thanks for the hint though, I'll check if the requests with a trailing slash reaches WP. Then I'll focus on the proxy package, I wanted to make sure the .htaccess configuration is correct before doing so.nginx
?.htaccess
is an Apache configuration file and has nothing to do with Nginx.