Answer the question
In order to leave comments, you need to log in
How to set up NGINX for Wordpress CNC?
Hello, please help me to make .htaccess work on Nginx + Php-fpm
There is a site on Wordpress, I use the latest version of VestaCP as a panel.
Previously, all I had to do was select the WebNGINX "wordpress2" template for the domain. After installing the latest version (16), all internal links with this template do not work. The main one loads properly, but the internal ones give out 404.
I found this instruction ( goo.gl/uik5eU):
"try_files $uri $uri/ /index.php?$args;" /home/мой пользователь/conf/web/.
"try_files $uri $uri/ /index.php?$args;" Needs to be added to the location section of each website you host.
server {
listen %ip%:%web_port%;
server_name %domain_idn% %alias_idn%;
root %docroot%;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/%domain%.log combined;
access_log /var/log/nginx/domains/%domain%.bytes bytes;
error_log /var/log/nginx/domains/%domain%.error.log error;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri $uri/ /index.php?$args;
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
}
location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass %backend_lsnr%;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
error_page 403 /error/404.html;
error_page 404 /error/404.html;
error_page 500 502 503 504 /error/50x.html;
location /error/ {
alias %home%/%user%/web/%domain%/document_errors/;
}
location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}
include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include /etc/nginx/conf.d/webmail.inc*;
include %home%/%user%/conf/web/nginx.%domain%.conf*;
}
Answer the question
In order to leave comments, you need to log in
All that is needed for CNC in WordPres + Nginx is:
1. try_files $uri $uri/ /index.php?$args;
in the config
2. Resave permalinks (WordPress admin - Settings - Permalinks)
If it doesn't work, the problem is elsewhere. We need to look at the logs, start with Nginx access.log and error.log
In root location:
if (!-e $request_filename ) { rewrite ^(.*)$ /index.php?q=$1; }
Hello, I decided to switch from Apache to php-fpm and ran into a problem, please help.
I have my code in .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
location / {
if (!-e $request_filename){
rewrite ^(.*)$ /index.php break;
}
}
location / {
location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
expires max;
}
location ~ [^/]\.php(/|$) {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass 127.0.0.1:9004;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question