Welcome! Log In Create A New Profile

Advanced

Help with Wordpress Rewrite Rules

Posted by ffernic 
Help with Wordpress Rewrite Rules
August 13, 2009 08:10AM
Hello,

I have setup a Wordpress MU blog as [b]www.domain.com/blog[/b] on nginx.
Everything works fine except the rewrite rules.

The apache rules for WP MU I was using are:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>


The nginx rules I am using currently are :

location /blog/ {
if (!-e $request_filename) {
rewrite ^.+?(/.*\.php)$ /blog$1 last;
rewrite ^.+?(/wp-.*) /blog$1 last;
rewrite ^ /blog/index.php last;
}
}

Now although the URLs work properly my page design gets screwed up. The sidebar goes to the bottom and design gets weird. On removing these rules the page deisgn is fine but individual posts give a 404 error.
What is wrong with the my nginx rewrite rules?
Re: Help with Wordpress Rewrite Rules
August 15, 2009 06:55AM
I can't believe that those Apache rules worked properly, but if you say so.

I would do something like the following:
[code]
location /blog {
if (!-e $request_filename) {
rewrite ^/blog/(.*)$ /blog/index.php?q=$1 last;
}
}
[/code]

According to Igor Sysoev you could try also the following:
[code]
location / {
error_page 404 = //blog/index.php?q=$uri;
}
[/code]
Ref: http://article.gmane.org/gmane.comp.web.nginx.english/4739

--------------------------------------------------------------------------------
//richard.fussenegger.info
//movlib.org
Re: Help with Wordpress Rewrite Rules
August 17, 2009 04:01PM
nice thanks
Re: Help with Wordpress Rewrite Rules
August 28, 2009 11:26AM
Fleshgrinder Wrote:
[..]
> According to Igor Sysoev you could try also the
> following:
>
> location / {
> error_page 404 = //blog/index.php?q=$uri;
> }

What is the significance of the double slash? Just to avoid infinite loop?
Re: Help with Wordpress Rewrite Rules
August 30, 2009 10:21AM
Hi miradev, sorry the quoted rewrite rule isn't from me, it was created by Igor Sysoev and I can't answer your question. Maybe someone else can?

--------------------------------------------------------------------------------
//richard.fussenegger.info
//movlib.org
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 73
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready