wordpress rewrite nginx
Igor Sysoev
is at rambler-co.ru
Tue Feb 13 22:32:10 MSK 2007
On Tue, Feb 13, 2007 at 05:43:22PM +0200, Anonymous Coward wrote:
> Same... it just loads the next and the uploaded pictures from posts... all
> bulky with no design
>
> Now my config looks like:
>
> server {
> listen my.ip;
> server_name sub.domain.tld;
> root /var/www/localhost/htdocs/sub.domain.tld;
>
> access_log /var/log/nginx/sub.domain.tld.access_log
> main;
> error_log /var/log/nginx/sub.domain.tld.error_log;
>
> rewrite ^(.*)?/?files/(.*) /wp-content/blogs.php?file=$2;
>
> location / {
> root /var/www/localhost/htdocs/sub.domain.tld;
> allow 192.168.2.0/24;
> deny all;
>
> if (!-e $request_filename) {
> rewrite ^([_0-9a-zA-Z-]+)?(/wp-.*) $2 last;
> rewrite ^([_0-9a-zA-Z-]+)?(/.*\.php)$ $2 last;
> rewrite ^ /index.php last;
> }
> }
> location ~ .php$ {
> include /etc/nginx/fastcgi_params;
> fastcgi_pass 127.0.0.1:1105;
> fastcgi_index index.php;
>
> # where the php files to pass to the listener.
> fastcgi_param SCRIPT_FILENAME
>
> /var/www/localhost/htdocs/sub.domain.tld$fastcgi_script_name;
> }
> }
> }
Well, try the following:
server {
listen my.ip;
server_name sub.domain.tld;
access_log /var/log/nginx/sub.domain.tld.access_log main;
error_log /var/log/nginx/sub.domain.tld.error_log;
root /var/www/localhost/htdocs/sub.domain.tld;
rewrite ^(.*)?/?files/(.*) /wp-content/blogs.php?file=$2;
location / {
allow 192.168.2.0/24;
deny all;
if (!-e $request_filename) {
rewrite ^([_0-9a-zA-Z-]+)?(/wp-.*) $2 break; # NOTE BREAK
rewrite ^([_0-9a-zA-Z-]+)?(/.*\.php)$ $2 last;
rewrite ^ /index.php last;
}
}
location ~ .php$ {
fastcgi_pass 127.0.0.1:1105;
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
# where the php files to pass to the listener.
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
It's seems that "^([_0-9a-zA-Z-]+)?(/wp-.*)" are static files, so "break"
stops rewrite cycle. The "last" continues rewrite cycle and request will
go to "location ~ .php$".
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list