Support » Fixing WordPress » WordPress strips subdirectory at some wp-admin pages with apache2 reverse proxy

  • I am using apache2 and mod-proxy to integrate wordpress blogs into subdirectories of my TLD.

    • Main site:
    • Blog1: []
    • Blog2: []

    Apach2 virtual host of the main site with proxy:

    <VirtualHost *:80>
    # Rewrite rule to add missing slashes
    RewriteRule ^/blog$ /blog/ [R=301]
    RewriteRule ^/other-blog$ /other-blog/ [R=301]
    <Proxy *>
    Order deny,allow
    Allow from all
    ProxyRequests off
    ProxyPass /blog/ http://blog1.localhost/
    ProxyPassReverse /blog/ http://blog1.localhost/
    ProxyPass /other-blog/ http://blog2.localhost/
    ProxyPassReverse /other-blog/ http://blog2.localhost/

    Apach2 virtual hosts for blogs:

    <VirtualHost *:80>
    ServerName blog1.localhost
    DocumentRoot /var/www/blog1/
    <Directory />
    Options FollowSymLinks
    AllowOverride All

    Linux hosts file add lines:     blog1.localhost localhost.localdomain     blog2.localhost localhost.localdomain

    WordPress: Settings > General Settings:

    • WordPress address (URL): []
    • Site address (URL): []

    The .htaccess file:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

    The problem:

    This setup works fine in general. Unfortunately the back end of WordPress has problems at some parts by stripping the sub-folders in URLs resulting in problems on some pages in wp-admin as saving settings, inserting pictures from the add picture tool, removing plugins. eg.:

    • Uses: […]
    • Should use: […]


    • Uses: […]
    • Should use: […]

    What I tried so far:

    1. Various apache2 configurations and rewrite rules eg.:

    ProxyPreserveHost On
    RewriteRule ^|admin|includes).*)$1 [R=301,L]
    RewriteRule ^wp-admin/(.*)$$1 [L,R=301]

    2. used various modifications in wp-config.php found at

    define('WP_HOME',  'http://' . $_SERVER['HTTP_HOST'] . '/blog');
    define('WP_HOME', '');
    define('WP_SITEURL', '' . $_SERVER['SERVER_NAME'] . '/blog');
    define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/blog');
    define('WP_SITEURL', '');

    3. Searched the mySQL database for wrong set URLs.

    Nothing of it worked so far or made it worse.

    If somebody has an idea of how to solve this problem I would very much appreciate this.

    Note: I’m having the same problem at different language versions of wordpress 3.2.1. I’m using Ubuntu 10.04 Server.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Are you using the same database for all three sites? That is the only thing I could think that would cause an issue like that – I’ve hosted multiple wordpress installs on the same domain plenty of times (both shared and VPS hosting) and never had any issues with permalinks, but they all used different databases.

    Maybe it would be better to go with WPMU to manage multiple blogs on one domain? It is not too hard to set up:

    Hi Mchelles,

    yes, I am actually using the same database for all blogs. But I use different two letter prefixes for each blog: XX_tables

    Do you anyhow think that this could be the problem? If so, I will create a separate database for each blog.

    I thought of using WPMU. I’ll give it a try if I’m not able to fix this issue soon.

    Thanks for your help so far 🙂

    Update: I created a new blog using a separate database. Unfortunately it did not solve that problem.

    I have exactly the same problem. Really annoying!
    Anyone an idea?
    thx talkstar


    Unfortunately I haven’t found a solution so far as well. I didn’t got the time to try WPMU.
    Actually you can work around somehow by correcting the URL. But it is annoying, yes!

    I guess it’s a bug that only appears with this setup.

    unfortunately in my wordpress this problem also exists with some plugins (e.g. NextGEN Gallery). so it’s not only in the backend, but sometimes even in the front end which is really annoying…

    i probably found a solution. at leasts this seems to work fine for me. no more problems found:

    in wp-config.php

    $_SERVER['REQUEST_URI'] = '/subdirectory' . $_SERVER['REQUEST_URI'];
    $_SERVER['SCRIPT_NAME'] = '/subdirectory' . $_SERVER['SCRIPT_NAME'];
    $_SERVER['PHP_SELF'] = '/subdirectory' . $_SERVER['PHP_SELF'];
    define('WP_HOME', '');
    define('WP_SITEURL', '');

    What if you installed WordPress into the /blog/ subdirectory of your blog vhost, instead of trying to remap the directory?

    I am also having this problem. I’ve got a single WordPress install, reverse proxied behind Ubuntu 10.04 server, with a single WP database on a separate server, with a similar configuration to the OP, and I’m seeing the same behaviour.

    What if you installed WordPress into the /blog/ subdirectory of your blog vhost, instead of trying to remap the directory?

    This would probably work, but it’s a kludge. When configured correctly, reverse proxying works for the most part, but there’s a few pages in wp-admin that cause a redirect to the root page, which is a bug.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘WordPress strips subdirectory at some wp-admin pages with apache2 reverse proxy’ is closed to new replies.