# Nginx and WordPress in a subdirectory

**URL:** <https://www.ruby-forum.com/t/nginx-and-wordpress-in-a-subdirectory/236109>\
**Category:** NGINX\
**Created:** [August 6, 2013, 7:41am UTC](https://www.ruby-forum.com/t/nginx-and-wordpress-in-a-subdirectory/236109 "2013-08-06T07:41:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [August 6, 2013, 7:41am UTC](https://www.ruby-forum.com/t/nginx-and-wordpress-in-a-subdirectory/236109/1 "2013-08-06T07:41:22Z")

</div>

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;
    proxy_pass http://nsweb1.nstein.prod:90;
}

```

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\>  
ServerName [www.sitename.com](http://www.sitename.com)  
ServerAlias nsweb1.nstein.prod

```
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’, ‘[http://www.sitename.com/advertise-wp](http://www.sitename.com/advertise-wp)’);  
define(‘WP\_SITEURL’, ‘[http://www.sitename.com/advertise-wp](http://www.sitename.com/advertise-wp)’);

Thanks for your help.

Posted at Nginx Forum:

> **[nginx and WordPress in a subdirectory](https://forum.nginx.org/read.php?2,241623,241623#msg-241623)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![daveyfx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b487fb/32.png) [@daveyfx](https://www.ruby-forum.com/u/daveyfx)\
**Post date:** [August 6, 2013, 8:29am UTC](https://www.ruby-forum.com/t/nginx-and-wordpress-in-a-subdirectory/236109/2 "2013-08-06T08:29:16Z")

</div>

did you tried to --turn it off and on again – check it w/out the  
Rewrite-Stuff in your apache-config?

Where did you got that snippet from?

your RewriteBase looks fishy

Posted at Nginx Forum:

> **[Re: nginx and WordPress in a subdirectory](https://forum.nginx.org/read.php?2,241623,241625#msg-241625)**
>
> 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...
