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]

By default, WordPress generates all links without the trailing slash.

I can access the following:




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?
    – MrWhite
    Jan 27, 2021 at 23:22
  • Are you sure the problem isn't your proxy? If your WP install is at /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
    – Tom J Nowell
    Jan 28, 2021 at 0:02
  • 1
    @MrWhite I'm sorry, my bad - I put the /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.
    – krzk
    Jan 28, 2021 at 1:21
  • Why have you tagged this question with nginx? .htaccess is an Apache configuration file and has nothing to do with Nginx. Jan 28, 2021 at 8:23
  • @RichardSmith It would seem the Apache server is behind an Nginx proxy.
    – MrWhite
    Jan 28, 2021 at 10:47


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.