Answer the question
In order to leave comments, you need to log in
How to add multiple locations in nginx?
I decided to move the project from Apache to Nginx, but there were problems with several locations, before moving the rules to htaccess were as follows:
RewriteEngine on
RewriteBase /
RewriteRule ^js/(.*) compress/js.php?load=$1 [QSA,L]
RewriteRule ^css/(.*) compress/css.php?load=$1 [QSA,L]
RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) index.php [QSA,L]
server {
server_name dev.test.ru www.dev.test.ru;
charset UTF-8;
index index.html index.php;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/dev.test.ru/*.conf;
access_log /var/www/httpd-logs/dev.test.ru.access.log;
error_log /var/www/httpd-logs/dev.test.ru.error.log notice;
ssi on;
set $root_path /var/www/www-root/data/www/dev.test.ru;
root $root_path;
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
location /js {
rewrite ^/js/(.*) /compress/js.php?load=$1 break;
}
location /css {
rewrite ^/css/(.*) /compress/css.php?load=$1 break;
}
location / {
try_files $uri $uri/ /index.php?$args; # permalinks
}
}
listen 12.12.12.38:80;
location @php {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f info@test.ru";
fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
try_files $uri =404;
include fastcgi_params;
}
}
server {
server_name dev.test.ru www.dev.test.ru;
ssl on;
ssl_certificate "/var/www/httpd-cert/www-root/dev.test.ru.crt";
ssl_certificate_key "/var/www/httpd-cert/www-root/dev.test.ru.key";
ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
add_header Strict-Transport-Security "max-age=31536000;";
ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
charset UTF-8;
index index.html index.php;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/dev.test.ru/*.conf;
access_log /var/www/httpd-logs/dev.test.ru.access.log;
error_log /var/www/httpd-logs/dev.test.ru.error.log notice;
ssi on;
set $root_path /var/www/www-root/data/www/dev.test.ru;
root $root_path;
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
location /js {
rewrite ^/js/(.*) /compress/js.php?load=$1 break;
}
location /css {
rewrite ^/css/(.*) /compress/css.php?load=$1 break;
}
location / {
try_files $uri $uri/ /index.php?$args; # permalinks
}
}
listen 12.12.12.38:443;
location @php {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f info@test.ru";
fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
try_files $uri =404;
include fastcgi_params;
}
}
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
location /js {
rewrite ^/js/(.*) /compress/js.php?load=$1 break;
}
location /css {
rewrite ^/css/(.*) /compress/css.php?load=$1 break;
}
location / {
try_files $uri $uri/ /index.php?$args; # permalinks
}
}
Answer the question
In order to leave comments, you need to log in
The issue is resolved, the service for converting htaccess to config for Nginx helped awww.anilcetin.com
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question