Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 198 Vote(s) - 3.43 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multi Site WordPress rewrite rules in Nginx

#1
I'm trying to run a multi domain blog installation with WordPress and Nginx. The last step is to configure some rewrite rules in `.htaccess` (apache only) for the webserver. How do I translate this into Nginx rewrite rules?

RewriteEngine On
RewriteBase /

RewriteRule ^index\.php$ - [L]

# uploaded files
RewriteRule ^files/(.+) wp-includes/ms-files.php?file=$1 [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
RewriteRule . index.php [L]
Reply

#2
Above is missing a space after the rewrite ^.*/files/(.*(html|jpg|....... you need a space after the $ and before /wp-includes/ms-files.php. Cheers!
Reply

#3
[nginx rewrite rules example for Wordpress 3][1] :

server{
server_name *.example.com;
listen 80;
#on server block
##necessary if using a multi-site plugin
server_name_in_redirect off;
##necessary if running Nginx behind a reverse-proxy
port_in_redirect off;
access_log /var/log/nginx/example-com-access.log;

location / {
root /var/www/example.com/wordpress;
index index.html index.htm index.php;
rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
if (!-e $request_filename) {
rewrite ^.+/?(/wp-.*) $1 last;
rewrite ^.+/?(/.*\.php)$ $1 last;
rewrite ^(.+)$ /index.php?q=$1 last;
}
}

location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
{
root /var/www/example.com/wordpress;
rewrite ^/.*(/wp-.*/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ /wp-includes/ms-files.php?file=$1 last;
expires 30d;
break;
}

location ~ wp\-.*\.php|wp\-admin|\.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/example.com/wordpress$fastcgi_script_name;
}
}

[1]:

[To see links please register here]

Reply

#4
Instead of:

location ~ wp\-.*\.php|wp\-admin|\.php$ {

Change it to:

location ~ .php$

Allows it to direct

blog.com/wp-admin

to

blog.com/wp-admin/

Reply

#5
This nginx rewrite rules for WordPress have solved my problem perfectly,including changing ex.com/wp-admin to ex.com/wp-admin/.

But i've found a bug inside which wasted me several hours as follows:
If the static url include `.html` just like `/%category%/%post_id%.html`,you have to insted of:

<!-- begin snippet: js hide: false -->

<!-- language: lang-html -->

location ~* ^.+\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
{
root /var/www/example.com/wordpress;
rewrite ^/.*(/wp-.*/.*\.(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^.*/files/(.*(html|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ /wp-includes/ms-files.php?file=$1 last;
expires 30d;
break;
}

<!-- end snippet -->

Change it to:

<!-- begin snippet: js hide: false -->

<!-- language: lang-html -->

location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$
{
root /var/www/example.com/wordpress;
rewrite ^/.*(/wp-.*/.*\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ $1 last;
rewrite ^.*/files/(.*(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js))$ /wp-includes/ms-files.php?file=$1 last;
expires 30d;
break;
}

<!-- end snippet -->

Or,u'll had '404 page not found' error in the content pages!
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through