Forums

rewrite rules WordPress mu apache -> nginx (2 posts)

  1. pepejose
    Member
    Posted 2 months ago #

    APACHE

    RewriteEngine On
    RewriteBase /

    #uploaded files
    RewriteRule ^(.*/)?files/$ index.php [L]
    RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]

    RewriteCond %{REQUEST_FILENAME} -f [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule . - [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
    RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
    RewriteRule . index.php [L]

    NGINX

    rewrite ^/(.*/)?files/$ index.php last;
    rewrite ^/(.*/)?files/(.*) wp-content/blogs.php?file=$2 last;

    if (!-e $request_filename) {
    rewrite ^/([_0-9a-zA-Z-]+/)?(wp-.*) $2 last;
    rewrite ^/([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 last;
    rewrite ^/(.*)$ index.php last;
    }

    well, I searched and google and have tried various rules but was not able to work well

    any help?

    thank you very much

  2. pepejose
    Member
    Posted 1 month ago #

    I can not fix it, this is my actual setup, i tried everything I found on google

    server{
    listen *:80;
    server_name subdomain.domain.com;
    root /xx/xxx/xxxx/;
    index index.php index.html index.htm;

    #necessary if using a multi-site plugin
    server_name_in_redirect off;
    #necessary if running Nginx behind a reverse-proxy
    port_in_redirect off;

    # This will reject all external requests for files with names beginning with . (dot).
    location ~ /\. {
    deny all;
    }

    #mod rewrite wordpress

    rewrite ^.*/files/(.*) /wp-content/blogs.php?file=$1;
    if (!-e $request_filename) {
    rewrite ^.+?(/wp-.*) $1 last;
    rewrite ^.+?(/.*\.php)$ $1 last;
    rewrite ^ /index.php last;
    }

    #Proxy the PHP scripts to Apache listening on 127.0.0.1:8080
    location ~ \.php$ {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://127.0.0.1:8080;
    }
    }

    server_name_in_redirect off; and port_in_redirect off; directives have not helped

    The result is:

    - All resquests loads index (blogs planet)
    - Images of blogs generates 404....

    I have analyzed this last a bit, and the problem is that for example:

    http://subdomain.domain.com/userblog/files/2008/04/image.jpg == http://subdomain.domain.com/wp-content/blogs.php?file=2008/04/image.jpg

    the result is -> 404 — File not found.

    because do not select fine the id of the blog, id take it out of the database according to userblog, isn´t it? in that case '/userblog/' lost when apply the rewrite rule!!

    http://subdomain.domain.com/wp-content/blogs.dir/ correct IdBlog is 2 to this userblog but always is 1 /files/2008/04/image.jpg

    I'm going crazy, please help!

Reply

You must log in to post.

About this Topic