# Location ~ \\.php$ does not work with proxy\_pass breaks pretty permalinks

**URL:** <https://www.ruby-forum.com/t/location-php-does-not-work-with-proxy-pass-breaks-pretty-permalinks/179698>\
**Category:** NGINX\
**Created:** [December 2, 2009, 9:29am UTC](https://www.ruby-forum.com/t/location-php-does-not-work-with-proxy-pass-breaks-pretty-permalinks/179698 "2009-12-02T09:29:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nerdgrind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f14d63/32.png) [@nerdgrind](https://www.ruby-forum.com/u/nerdgrind)\
**Post date:** [December 2, 2009, 9:29am UTC](https://www.ruby-forum.com/t/location-php-does-not-work-with-proxy-pass-breaks-pretty-permalinks/179698/1 "2009-12-02T09:29:51Z")

</div>

I am using Nginx as a frontend server to server only static files, and  
apache as the backend server to serve only php file. I saw a  
configuration for proxy\_pass that would allow me to be 100% sure I was  
only serving php files by using the expression~ .php$. I saw this from  
a reply from Igor in [Reverse Proxy with caching](http://forum.nginx.org/read.php?2,13955)

I am currently using:

server …

location / {  
proxy\_pass [http://127.0.0.1:8008](http://127.0.0.1:8008);

location ~  
.(html|htm|xml|css|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$  
{  
root /var/www/mydomain;  
index index.php index.html index.htm;

In the static location I can isolate what is served by Nginx to just the  
files listed, but in the proxy\_pass location I can only use “/” so I  
can’t be sure only php files are served by apache. I would like to use  
the following:

location ~ .php$ {  
proxy\_pass [http://127.0.0.1:8008](http://127.0.0.1:8008);

This works with fast\_cgi, but not with proxy\_pass.

When I do use ~ .php$ I can only see the homepage, but not the post  
pages, page2, or anything but the home page. I am using Wordpress with  
pretty permalinks. I also use WP Super Cache.

How do I know I am only serving php files with Apache? Is there an  
expression I can use to force the location for proxy\_pass to only serve  
php files without breaking my pretty permalinks?

Posted at Nginx Forum:

> **[location ~ \\.php$ does not work with proxy\_pass breaks pretty permalinks](https://forum.nginx.org/read.php?2,27301,27301#msg-27301)**
>
> I am using Nginx as a frontend server to server only static files, and apache as the backend server to serve only php file. I saw a configuration for proxy\_pass that would allow me to be 100% sure I was only serving php files by using the expression~...

---

<div class="post-metadata">

**Author:** ![nerdgrind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f14d63/32.png) [@nerdgrind](https://www.ruby-forum.com/u/nerdgrind)\
**Post date:** [December 3, 2009, 5:06am UTC](https://www.ruby-forum.com/t/location-php-does-not-work-with-proxy-pass-breaks-pretty-permalinks/179698/2 "2009-12-03T05:06:19Z")

</div>

My question was answered in this other thread:

> **[Location container read order](https://forum.nginx.org/read.php?2,27566)**
>
> I have one "location" container that servers static content: location ~ \\.(html|htm|xml|css|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ and another "location" container that...

Posted at Nginx Forum:

> **[Re: location ~ \\.php$ does not work with proxy\_pass breaks pretty permalinks](https://forum.nginx.org/read.php?2,27301,27583#msg-27583)**
>
> I am using Nginx as a frontend server to server only static files, and apache as the backend server to serve only php file. I saw a configuration for proxy\_pass that would allow me to be 100% sure I was only serving php files by using the expression~...

---

<div class="post-metadata">

**Author:** ![nerdgrind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f14d63/32.png) [@nerdgrind](https://www.ruby-forum.com/u/nerdgrind)\
**Post date:** [December 3, 2009, 9:58am UTC](https://www.ruby-forum.com/t/location-php-does-not-work-with-proxy-pass-breaks-pretty-permalinks/179698/3 "2009-12-03T09:58:19Z")

</div>

Here is an example:

> **[Nerd Grind](https://www.nerdgrind.com)**
>
> NerdGrind is your one-stop-shop for all things Mac. As a Mac user myself, I publish news, honest reviews, and buying guides for my readers.

The homepage loads normally at the address [http://www.nerdgrind.com/](http://www.nerdgrind.com/),  
but anything else, for example [Nerd Grind](http://www.nerdgrind.com/page/2/) or  
single article pages like the example above, won’t load at all.

All the best,

Todd

Posted at Nginx Forum:

> **[Re: location ~ \\.php$ does not work with proxy\_pass breaks pretty permalinks](https://forum.nginx.org/read.php?2,27301,27445#msg-27445)**
>
> I am using Nginx as a frontend server to server only static files, and apache as the backend server to serve only php file. I saw a configuration for proxy\_pass that would allow me to be 100% sure I was only serving php files by using the expression~...

---

<div class="post-metadata">

**Author:** ![nerdgrind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f14d63/32.png) [@nerdgrind](https://www.ruby-forum.com/u/nerdgrind)\
**Post date:** [December 3, 2009, 4:13pm UTC](https://www.ruby-forum.com/t/location-php-does-not-work-with-proxy-pass-breaks-pretty-permalinks/179698/4 "2009-12-03T16:13:30Z")

</div>

I tried to use ~ .php$ again today to only serve php pages with the  
backend with proxy\_pass but I got this error:

404 Not Found

Todd

Posted at Nginx Forum:

> **[Re: location ~ \\.php$ does not work with proxy\_pass breaks pretty permalinks](https://forum.nginx.org/read.php?2,27301,27534#msg-27534)**
>
> I am using Nginx as a frontend server to server only static files, and apache as the backend server to serve only php file. I saw a configuration for proxy\_pass that would allow me to be 100% sure I was only serving php files by using the expression~...

---

<div class="post-metadata">

**Author:** ![nerdgrind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/f14d63/32.png) [@nerdgrind](https://www.ruby-forum.com/u/nerdgrind)\
**Post date:** [December 19, 2009, 3:25pm UTC](https://www.ruby-forum.com/t/location-php-does-not-work-with-proxy-pass-breaks-pretty-permalinks/179698/5 "2009-12-19T15:25:27Z")

</div>

X-Subject: Re: location ~ .php$ does not work with proxy\_pass breaks  
pretty  
permalinks

On Wed, Dec 02, 2009 at 03:24:31AM -0500, nerdgrind wrote:

> ```
> root /var/www/mydomain;
> 
> ```
> 
> How do I know I am only serving php files with Apache? Is there an expression I can use to force the location for proxy\_pass to only serve php files without breaking my pretty permalinks?

How do these pretty permalink URLs look ?

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**
