# Wordpress Permalinks

**URL:** <https://www.ruby-forum.com/t/wordpress-permalinks/216921>\
**Category:** NGINX\
**Created:** [February 17, 2012, 12:10am UTC](https://www.ruby-forum.com/t/wordpress-permalinks/216921 "2012-02-17T00:10:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [February 17, 2012, 12:10am UTC](https://www.ruby-forum.com/t/wordpress-permalinks/216921/1 "2012-02-17T00:10:43Z")

</div>

Howdy.

So I am trying to get permalinks to work with Wordpress. I have read a  
few articles/blog posts but still no luck. The permalink structure I am  
trying to use is:

[http://mydomain.com/wp/index.php/2012/02/sample-post/](http://mydomain.com/wp/index.php/2012/02/sample-post/)

Here is the configuration block that I am currently using that is  
important:

# permalinks currently not working with this

location ~ .php$ {  
include /etc/nginx/fastcgi\_params;  
fastcgi\_intercept\_errors off;  
fastcgi\_index index.php;

```
 try_files $uri $uri/ /index.php?q=$uri&$args;

 # tried this as well, but still doesn't work
 #
 #if (!-e $request_filename) {
 # rewrite ^.*$ /index.php last;
 #}

 fastcgi_pass php1.local.mydomain.com:9000;

```

}

Posted at Nginx Forum:

> **[Wordpress Permalinks](https://forum.nginx.org/read.php?2,222511,222511#msg-222511)**
>
> Howdy. So I am trying to get permalinks to work with Wordpress. I have read a few articles/blog posts but still no luck. The permalink structure I am trying to use is: http://mydomain.com/wp/index.php/2012/02/sample-post/ Here is the configuration...

---

<div class="post-metadata">

**Author:** ![justin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@justin](https://www.ruby-forum.com/u/justin)\
**Post date:** [February 17, 2012, 12:45am UTC](https://www.ruby-forum.com/t/wordpress-permalinks/216921/2 "2012-02-17T00:45:23Z")

</div>

On Fri, Feb 17, 2012 at 6:10 AM, justin [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Howdy.
> 
> So I am trying to get permalinks to work with Wordpress. I have read a  
> few articles/blog posts but still no luck. The permalink structure I am  
> trying to use is:
> 
> [http://mydomain.com/wp/index.php/2012/02/sample-post/](http://mydomain.com/wp/index.php/2012/02/sample-post/)

I believe it’s easier to use this structure:

[http://mydomain.com/wp/2012/02/sample-post/](http://mydomain.com/wp/2012/02/sample-post/)

(I don’t know why wordpress doesn’t offer this form for nginx by  
default)

Anyway, you need to move try\_files outside location ~ .php$ block.  
You also need split path info (and remove $ to match  
/wp/index.php/2012/02/sample-post/) or add one more location block to  
specifically handle the url.

> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

–  
O\< ascii ribbon campaign - stop html mail - [www.asciiribbon.org](http://www.asciiribbon.org)

---

<div class="post-metadata">

**Author:** ![justin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@justin](https://www.ruby-forum.com/u/justin)\
**Post date:** [February 17, 2012, 12:57am UTC](https://www.ruby-forum.com/t/wordpress-permalinks/216921/3 "2012-02-17T00:57:48Z")

</div>

On 02-16 18:10, justin wrote:

> ```
> #if (!-e $request_filename) {
> # rewrite ^.*$ /index.php last;
> #}
> 
> fastcgi_pass php1.local.mydomain.com:9000;
> 
> ```
> 
> }

this is a solution i found for running wordpress behind nginx and it  
works 🙂

location / {  
set $rewrite\_to\_php “true”;  
if ( -f $request\_filename) {  
set $rewrite\_to\_php “false”;  
}  
if ( -d $request\_filename) {  
set $rewrite\_to\_php “false”;  
}  
if ( $rewrite\_to\_php = “true” ) {  
rewrite ^(.\*)$ /index.php?q=$1 last;  
break;  
}  
}

location ~\* .(jpg|jpeg|gif|css|png|js|ico|html)$ {  
expires max;  
}

location ~\* .php$ {  
include /etc/nginx/fastcgi\_params;  
fastcgi\_index index.php;  
fastcgi\_pass 127.0.0.1:9000;  
}

if you depend on try\_files you might change the “location /” section  
this way:

location / {  
try\_files $uri $uri/ /index.php?q=$1;  
}

i didn’t test it, but as written in the wiki, this should work also 🙂

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

bye MUH!

–  
; **;** _,  
)..(_=\_)  
(oo)| |

---

<div class="post-metadata">

**Author:** ![justin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@justin](https://www.ruby-forum.com/u/justin)\
**Post date:** [February 17, 2012, 3:46am UTC](https://www.ruby-forum.com/t/wordpress-permalinks/216921/4 "2012-02-17T03:46:51Z")

</div>

This article might be of interest:

> **[Running WordPress On Nginx (LEMP) On Debian Squeeze/Ubuntu 11.04](https://www.howtoforge.com/running-wordpress-on-nginx-lemp-on-debian-squeeze-ubuntu-11.04)**
>
> Running WordPress On Nginx (LEMP) On Debian Squeeze/Ubuntu 11.04
> 
> This tutorial shows how you can install and run a WordPress blog on a
> Debian Squ...

It’s using the following permalink structure:  
/%year%/%monthnum%/%day%/%postname%/  
But I think the other options should work as well.

----- Original Message -----  
From: “justin” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Friday, February 17, 2012 12:10 AM  
Subject: Wordpress Permalinks

---

<div class="post-metadata">

**Author:** ![justin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3ab097/32.png) [@justin](https://www.ruby-forum.com/u/justin)\
**Post date:** [February 17, 2012, 8:23am UTC](https://www.ruby-forum.com/t/wordpress-permalinks/216921/5 "2012-02-17T08:23:01Z")

</div>

Falko,

Thanks for the link, that worked, got permalinks going. Whoot.

Posted at Nginx Forum:

> **[Re: Wordpress Permalinks](https://forum.nginx.org/read.php?2,222511,222529#msg-222529)**
>
> Howdy. So I am trying to get permalinks to work with Wordpress. I have read a few articles/blog posts but still no luck. The permalink structure I am trying to use is: http://mydomain.com/wp/index.php/2012/02/sample-post/ Here is the configuration...
