# Can not make WordPress pretty permalinks work (404 error)

**URL:** <https://www.ruby-forum.com/t/can-not-make-wordpress-pretty-permalinks-work-404-error/219620>\
**Category:** NGINX\
**Created:** [May 9, 2012, 1:51pm UTC](https://www.ruby-forum.com/t/can-not-make-wordpress-pretty-permalinks-work-404-error/219620 "2012-05-09T13:51:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [May 9, 2012, 1:51pm UTC](https://www.ruby-forum.com/t/can-not-make-wordpress-pretty-permalinks-work-404-error/219620/1 "2012-05-09T13:51:25Z")

</div>

I’ve tried to follow the guide at

> **[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...

as suggested in the post  
[Re: Wordpress Permalinks](http://forum.nginx.org/read.php?2,222511,222517#msg-222517) , but it  
still doesn’t work. I’ve copied and replaced the server settings from  
the guide, and changed the parts pertaining to my server.

Any permalink setting other than default results in a 404 error page  
when accessing the permalink. The permalinks all have the form  
[http://wp.dev/sitename/sample-page](http://wp.dev/sitename/sample-page). There’s no structure created for the  
tags month, year etc. in the url.

Could someone please help me?

Posted at Nginx Forum:

> **[can not make WordPress pretty permalinks work (404 error)](https://forum.nginx.org/read.php?2,226209,226209#msg-226209)**
>
> I've tried to follow the guide at http://www.howtoforge.com/running-wordpress-on-nginx-lemp-on-debian-squeeze-ubuntu-11.04 as suggested in the post http://forum.nginx.org/read.php?2,222511,222517#msg-222517 , but it still doesn't work. I've copied...

---

<div class="post-metadata">

**Author:** ![seron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/779978/32.png) [@seron](https://www.ruby-forum.com/u/seron)\
**Post date:** [May 9, 2012, 2:19pm UTC](https://www.ruby-forum.com/t/can-not-make-wordpress-pretty-permalinks-work-404-error/219620/2 "2012-05-09T14:19:22Z")

</div>

On Wed, May 9, 2012 at 6:50 PM, seron [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> tags month, year etc. in the url.

This may be able to help (my wordpress config).

location / {  
root /home/edho/sites/animebsd.net;  
index index.php;  
try\_files $uri $uri/ /index.php?q=$uri&$args;  
expires max;  
location ~ .php$ {  
expires off;  
try\_files $uri =404;  
fastcgi\_param SCRIPT\_FILENAME $request\_filename;  
include fastcgi\_params;  
fastcgi\_pass unix:/tmp/.php.sock-edho;  
}  
}

---

<div class="post-metadata">

**Author:** ![seron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/779978/32.png) [@seron](https://www.ruby-forum.com/u/seron)\
**Post date:** [May 9, 2012, 3:56pm UTC](https://www.ruby-forum.com/t/can-not-make-wordpress-pretty-permalinks-work-404-error/219620/3 "2012-05-09T15:56:12Z")

</div>

On Wed, May 9, 2012 at 8:51 PM, seron [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> For example the WordPress sample page can have either of these two  
> permalinks, depending on if permalinks are set to default or something  
> else:
> 
> [Sample Page – My WordPress](http://wptest.dev/?page_id=2) (default permalink setting)  
> [Sample Page – My WordPress](http://wptest.dev/index.php/sample-page/) (any other permalink setting)

Remove the /index.php part unless you really love it (I don’t) - which  
then this additional config is needed:

location /index.php/ {  
rewrite ^/index.php/(.+)$ /index.php?q=$1&$args;  
}

Make sure to put it before “location /” block.

---

<div class="post-metadata">

**Author:** ![seron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/779978/32.png) [@seron](https://www.ruby-forum.com/u/seron)\
**Post date:** [May 9, 2012, 3:51pm UTC](https://www.ruby-forum.com/t/can-not-make-wordpress-pretty-permalinks-work-404-error/219620/4 "2012-05-09T15:51:51Z")

</div>

I made a fresh install of WordPress in a new directory and made a  
separate server section in nginx.conf for it.

I tired what you suggested, but to no avail. There’s a small change  
which is that I don’t get a 404 error any more and the page is  
displayed. My guess is that it’s a different problem present in my  
original WordPress installation which is not present in the new one.

The problem with the pretty permalinks still remains however.

For example the WordPress sample page can have either of these two  
permalinks, depending on if permalinks are set to default or something  
else:

[http://wptest.dev/?page\_id=2](http://wptest.dev/?page_id=2) (default permalink setting)  
[http://wptest.dev/index.php/sample-page/](http://wptest.dev/index.php/sample-page/) (any other permalink setting)

My server section in nginx.conf looks like this following your  
suggestion:

server {  
listen 80;  
server\_name wptest.dev;  
root /var/www/localhost/wptest;

```
   index index.php;

   location / {
            try_files $uri $uri/ /index.php?q=$uri&$args;
            expires max;
   }

   location ~ \.php$ {
            expires off;
            try_files $uri =404;
            include fastcgi_params;
            fastcgi_pass localhost:65500;
            fastcgi_param SCRIPT_FILENAME $request_filename;
   }

```

}

Posted at Nginx Forum:  
[http://forum.nginx.org/read.php?2,226209,226215#msg-226215](http://forum.nginx.org/read.php?2,226209,226215#msg-226215)

---

<div class="post-metadata">

**Author:** ![seron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/779978/32.png) [@seron](https://www.ruby-forum.com/u/seron)\
**Post date:** [May 9, 2012, 4:12pm UTC](https://www.ruby-forum.com/t/can-not-make-wordpress-pretty-permalinks-work-404-error/219620/5 "2012-05-09T16:12:58Z")

</div>

That’s interesting. It doesn’t remove the index.php part. I’ve tried  
both first and last. Very odd.

Posted at Nginx Forum:

> **[Re: can not make WordPress pretty permalinks work](https://forum.nginx.org/read.php?2,226216,226218#msg-226218)**
>
> On Wed, May 9, 2012 at 8:51 PM, seron \<nginx-forum@nginx.us\> wrote: \> I made a fresh install of WordPress in a new directory and made a \> separate server section in nginx.conf for it. \> \> I tired what you suggested, but to no avail....

---

<div class="post-metadata">

**Author:** ![seron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/779978/32.png) [@seron](https://www.ruby-forum.com/u/seron)\
**Post date:** [May 9, 2012, 4:26pm UTC](https://www.ruby-forum.com/t/can-not-make-wordpress-pretty-permalinks-work-404-error/219620/6 "2012-05-09T16:26:02Z")

</div>

I’ve discovered something interesting. Permalinks works as expected for  
posts but not for pages. I’ve been trying all along with pages. Are  
pretty permalinks not supposed to work with pages?

Posted at Nginx Forum:

> **[Re: can not make WordPress pretty permalinks work](https://forum.nginx.org/read.php?2,226216,226219#msg-226219)**
>
> On Wed, May 9, 2012 at 8:51 PM, seron \<nginx-forum@nginx.us\> wrote: \> I made a fresh install of WordPress in a new directory and made a \> separate server section in nginx.conf for it. \> \> I tired what you suggested, but to no avail....

---

<div class="post-metadata">

**Author:** ![seron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/779978/32.png) [@seron](https://www.ruby-forum.com/u/seron)\
**Post date:** [May 9, 2012, 4:01pm UTC](https://www.ruby-forum.com/t/can-not-make-wordpress-pretty-permalinks-work-404-error/219620/7 "2012-05-09T16:01:10Z")

</div>

Sorry to jump in here, but I was led to believe that the order of blocks  
in  
the configuration file didn’t matter. If it does matter, then this wiki  
article needs updating: [http://wiki.nginx.org/HttpCoreModule#location](http://wiki.nginx.org/HttpCoreModule#location)

"Note that you could define these 4 configurations in any order and the  
results would remain the same. "

---

<div class="post-metadata">

**Author:** ![seron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/779978/32.png) [@seron](https://www.ruby-forum.com/u/seron)\
**Post date:** [May 9, 2012, 5:26pm UTC](https://www.ruby-forum.com/t/can-not-make-wordpress-pretty-permalinks-work-404-error/219620/8 "2012-05-09T17:26:19Z")

</div>

On Wed, May 9, 2012 at 9:33 PM, seron [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The location clause you suggested didn’t cut out the index.php part, but  
> a WordPress plugin called “nginx compatibility” did.

The location block I suggested is to handle permalinks with  
/index.php/. To remove it you can just modify the permalink structure  
in wordpress’ options page.

---

<div class="post-metadata">

**Author:** ![seron](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/779978/32.png) [@seron](https://www.ruby-forum.com/u/seron)\
**Post date:** [May 9, 2012, 4:34pm UTC](https://www.ruby-forum.com/t/can-not-make-wordpress-pretty-permalinks-work-404-error/219620/9 "2012-05-09T16:34:06Z")

</div>

The location clause you suggested didn’t cut out the index.php part, but  
a WordPress plugin called “nginx compatibility” did.

Posted at Nginx Forum:

> **[Re: can not make WordPress pretty permalinks work](https://forum.nginx.org/read.php?2,226216,226220#msg-226220)**
>
> On Wed, May 9, 2012 at 8:51 PM, seron \<nginx-forum@nginx.us\> wrote: \> I made a fresh install of WordPress in a new directory and made a \> separate server section in nginx.conf for it. \> \> I tired what you suggested, but to no avail....
