nginx and WordPress in a subdirectory

daveyfx nginx-forum at
Tue Aug 6 05:40:48 UTC 2013

Hello -

I've got nginx as a front-end to Apache and am trying to serve a single
WordPress site from a location on my site.  Right now I would like to test
the location, but it will eventually be served as /advertise.  I cannot get
the WordPress site to serve correctly, however as I am seeing a 301 redirect
infinite loop.

nginx location directive:

    location ^~ /advertise-wp {
        include /usr/local/nginx/proxypass.conf;

contents of /usr/local/nginx/proxypass.conf:
proxy_redirect     off;
proxy_set_header   Host             $host;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

Apache configuration:
Listen 90

<VirtualHost *:90>

    DocumentRoot /opt/nstein/advertise
    ErrorLog /var/log/apache2/www_error.log
    CustomLog /var/log/apache2/www_access.log combined
    DirectoryIndex index.php


<Directory "/opt/nstein/advertise">
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]

I have tried to make this work properly by setting these in wp-config.php as
well, to no avail.
define('WP_HOME', '');
define('WP_SITEURL', '');

Thanks for your help.

Posted at Nginx Forum:,241623,241623#msg-241623

More information about the nginx mailing list