I have a pretty weird nginx setup. I need the following setup:
url "/" -> static html files in /srv/www/landing-pages
url "/tr_tr/blog/*" -> wordpress installation in /srv/www/domain.com
url "/en_us/blog/*" -> wordpress installation in /srv/www/domain.com
The wordpress configuration is like
- currently the wordpress installation is configured to answer to domain.com.
- the whole /tr_tr/blog structure is constructed with wpml multi language plugin.
- two wordpress pages are created with "/blog" slug and are prefixed with locales by the wpml plugin.
- Blog post permalinks are set to /blog/%postname%-%post_id%/ Those permalinks are prefixed with locales by wpml automatically too.
My nginx configuration is
server {
server_name www.domain.com;
return 301 $scheme://domain.com$request_uri;
}
server {
listen 80;
listen [::]:80;
server_name domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name domain.com;
gzip on;
gzip_proxied any;
gzip_types
text/plain
text/xml
text/css
image/svg+xml
application/json
application/javascript
application/x-javascript;
gzip_vary on;
gzip_disable “MSIE [1-6]\.(?!.*SV1)”;
expires $expires;
ssl_certificate /etc/nginx/ssl/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/privkey.pem;
server_tokens off;
# include /etc/nginx/nginx-wp-common.conf;
location / {
root /srv/www/landing-pages;
index index.html index.htm;
try_files $uri $uri/ /$uri;
}
location /tr_tr/blog {
alias /srv/www/domain.com/;
index index.php;
try_files $uri $uri/ /index.php?$args =404;
location ~ \/tr_tr\/blog\/.*\.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_read_timeout 3600s;
fastcgi_param SCRIPT_FILENAME /srv/www/domain.com/$fastcgi_script_name;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
}
}
}
I added only tr_tr location during development. Currently I'm getting 404's 403's "No input file specified's" for blog urls.
Root urls are fine, I can open my dummy html files in srv/www/landing-pages folder from domain.com/test.html
The idea is,
- all urls should follow /{locale}/{project} template.
- corporate landing pages will be served from landing-pages folder (gatsbyjs)
- Company blog is served from /{locale}/blog urls
- I dont want to create two seperate wp installations for both countries.
How can I setup this configuration in nginx?