Wordpress permalink requires nginx rewrite rules

Bug #1244371 reported by Hamed Hemmati
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
wordpress (Juju Charms Collection)
In Progress
High
Marco Ceppi

Bug Description

When you switch the permalink to anything other than default you get bad gateway from nginx. After a little bit of investigation I realized the site information under sites-available of nginx is missing the rewrite rules.

This is what I added for mine and it works fine now. Please add this to juju wordpress charm.

# Wordpress permalinks
if (!-e $request_filename) {
 rewrite ^(.*)$ /index.php?q=$1 last;
 break;
}

Jorge Castro (jorge)
Changed in wordpress (Juju Charms Collection):
assignee: nobody → Marco Ceppi (marcoceppi)
status: New → Confirmed
Revision history for this message
Hamed Hemmati (hamed-5) wrote :

Is there any way to do a temporary fix? When I change the wordpress file under sites-availabe it works fine for a while and then it gets overwritten. I am doing a buddypress development so the permalink has to be changed to something other than default.

Marco Ceppi (marcoceppi)
Changed in wordpress (Juju Charms Collection):
status: Confirmed → In Progress
importance: Undecided → High
Revision history for this message
Marco Ceppi (marcoceppi) wrote :

If statements are terrible and unreliable Nginx constructs. I'll look for a better way to do rewrites in nginx and add it to the charm.

If you want to patch your version of the charm, you can edit the files in the deployed version of the charm by running `juju ssh wordpress/0`, from there, `sudoedit /var/lib/juju/agents/unit-wordpress-0/charm/files/charm/nginx/etc_nginx_sites-enabled_wordpress` and add that change to the template. That way it won't be overwritten when the charm processes events.

Revision history for this message
Hamed Hemmati (hamed-5) wrote :

Thanks that fix worked great.

When the charm does get upgraded with the fix will the upgrade overwrite these changes that I made to the template or do I have to manually remove the changes?

Revision history for this message
Hamed Hemmati (hamed-5) wrote :

Have you been able to add rewrite to the wordpress charm because every time I upgrade I have to add the fix.

Revision history for this message
Johan Ehnberg (johan-ehnberg) wrote :

The following is the recommended way to manage permalinks:

 location / {
    try_files $uri $uri/ /index.php?$args;
  }

Source:
http://codex.wordpress.org/Nginx

The page says "This was fixed in WordPress 3.7, which now detects nginx servers and enables "pretty" permalinks automatically. " Maybe there is even a way to do this automatically then?

Revision history for this message
Johan Ehnberg (johan-ehnberg) wrote :

It also seems that installing the plugin nginx-helper does not address this part of the issue, it still requires the rewrite rule.

Revision history for this message
Johan Ehnberg (johan-ehnberg) wrote :

Setting the engine to apache may be a way to get permalinks. However, I was unsuccessful and only got a blank page after switching. I might look into this in another report.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.