Nginx config for wordpress in subfolder with rewrites for main folder
sip
nginx-forum at nginx.us
Wed Apr 15 16:58:20 UTC 2015
I have a vbulletin site in root and a wordpress blog in /blog/
the root nginx rewrites all work as they should utilising the dbseo plugin
for vbulletin to make search engine friendly urls
if i turn on permalinks in wordpress i get a 404 error no matter what i
try.
Could anyone advise what the change should be to be able to use a different
set of rewrite rules in just the blog folder.
I am hoping to have other wordpress installs for different purposes so this
will hopefully explain for the future also.
Current domain.conf for nginx
-------------------------------------------
server {
listen 80;
#listen [::]:80 default ipv6only=on;
server_name www.mydomain.com mydomain.com;
root /home/username/domains/mydomain.com/public_html;
access_log /home/username/domains/mydomain.com/logs/access.log;
error_log /home/username/domains/mydomain.com/logs/error.log;
index index.php index.html index.htm;
error_page 404 /404.html;
location / {
try_files $uri $uri/ /dbseo.php;
}
location ~ ^((?!dbseo).)*\.php$
{
rewrite ^/(.*)$ /dbseo.php last;
}
# Pass PHP scripts to PHP-FPM
location ~ \.php$ {
try_files $uri =403;
fastcgi_split_path_info ^(/blog)(/.*)$;
fastcgi_pass unix:/var/run/php5-fpm-username.sock;
include fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
}
# Enable browser cache for CSS / JS
location ~* \.(?:css|js)$ {
expires 30d;
add_header Pragma "public";
add_header Cache-Control "public";
add_header Vary "Accept-Encoding";
}
# Enable browser cache for static files
location ~*
\.(?:ico|jpg|jpeg|gif|png|bmp|webp|tiff|svg|svgz|pdf|mp3|flac|ogg|mid|midi|wav|mp4|webm|mkv|og$
expires 60d;
add_header Pragma "public";
add_header Cache-Control "public";
}
# Deny access to hidden files
location ~ (^|/)\. {
deny all;
}
# Prevent logging of favicon and robot request errors
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; }
}
--------------------------------------------
I have tried a load of different options to get this to work.
I have posted these on stackoverflow which is possibly simpler than posting
again here.
thats here
http://stackoverflow.com/questions/29518899/nginx-config-for-wordpress-in-subfolder-with-rewrites-for-main-folder
Any help w2ould be most appreciated.
I think i just need the basics of how to ignore / include certain rules for
certain pages.
how do i make /blog/ only use its own rules and ignore everything else.?
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,258060,258060#msg-258060
More information about the nginx
mailing list