I'm having little problems with Nginx and Wordpress. We have not standard configuration where everything except defined folders and files will be sent to wordpress. And wordpress is in subdirectory /wordpress but it must behave like it's not. For now we managed to get this configuration working and here is part of it:
if ($request_uri ~ "^/(folder1|folder2|folder3|folder4)/") {
break;
}
if ($request_uri ~ "^/(file1\.ext1|file2\.ext2|file3\.ext3|file4\.ext4)") {
break;
}
if ($request_uri ~ "^/$") {
break;
}
if ($request_uri ~ "^/\?m\=[0-9]$") {
break;
}
rewrite ^/(.*)$ /wordpress/$1;
location ~ /wordpress {
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
rewrite /wp-admin$ /wp-admin/ permanent;
location ~ ^/wordpress/wp-admin/ {
include /etc/nginx/settings/moderator-access.conf;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
}
rewrite ^/?(.*)$ /wordpress/index.php?$1;
try_files $uri $uri/ /index.php?$args;
# Handling PHP files
include settings/php-fpm.conf;
}
Problem with this config (except being complex :)) is that when someone goes to www.example.com/wp-admin/ it gives 404 blank page. But what's interesting if you type www.example.com/wp-admin/index.php everything works excellent. Doe's anyone have idea how to fix this?
P.S. We recently switched to Nginx and we are still struggling with it :) It's not easy after 7 years on Apache to switch :)
if ($request_uri ~ "^/(folder1|folder2|folder3|folder4)/") {
break;
}
if ($request_uri ~ "^/(file1\.ext1|file2\.ext2|file3\.ext3|file4\.ext4)") {
break;
}
if ($request_uri ~ "^/$") {
break;
}
if ($request_uri ~ "^/\?m\=[0-9]$") {
break;
}
rewrite ^/(.*)$ /wordpress/$1;
location ~ /wordpress {
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
rewrite /wp-admin$ /wp-admin/ permanent;
location ~ ^/wordpress/wp-admin/ {
include /etc/nginx/settings/moderator-access.conf;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
}
rewrite ^/?(.*)$ /wordpress/index.php?$1;
try_files $uri $uri/ /index.php?$args;
# Handling PHP files
include settings/php-fpm.conf;
}
Problem with this config (except being complex :)) is that when someone goes to www.example.com/wp-admin/ it gives 404 blank page. But what's interesting if you type www.example.com/wp-admin/index.php everything works excellent. Doe's anyone have idea how to fix this?
P.S. We recently switched to Nginx and we are still struggling with it :) It's not easy after 7 years on Apache to switch :)