Как объединить эти 2 правила?
location / {
try_files $uri $uri/ /index.php?$args;
и авторизацию на определенных урл
location ~* (siteadmin|catalog) {
auth_basic "Restricted";
auth_basic_user_file /home/sitemarket/conf/web/.htpasswd;}
Срабатывает авторизация но перестают работать ЧПУ УРЛ и выдает 404 ошибку
Не могу сообразить как это все объединить чтобы работало и ЧПУ и авторизация на определенных УРЛ.
Вся конфигурация
server {
listen ip:443;
server_name site.kg www.site.kg;
root /home/sitemarket/web/site.kg/public_html;
index index.php index.html index.htm;
access_log /var/log/nginx/domains/site.kg.log combined;
access_log /var/log/nginx/domains/site.kg.bytes bytes;
error_log /var/log/nginx/domains/site.kg.error.log error;
if ($http_host = www.site.kg) {
rewrite (.*) https://site.kg$1;
}
ssl on;
ssl_certificate /home/sitemarket/conf/web/ssl.site.kg.pem;
ssl_certificate_key /home/sitemarket/conf/web/ssl.site.kg.key;
....
..........
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 site;
}
location ~* (siteadmin|catalog) {
auth_basic "Restricted";
auth_basic_user_file /home/sitemarket/conf/web/.htpasswd;}
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:9001;
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
fastcgi_read_timeout 3000;
..............
}
}
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/sitemarket/web/site.kg/document_errors/;
}
location ~* "/\.(htaccess|htpasswd)$" {
deny all;
return 404;
}
location /vstats/ {
alias /home/sitemarket/web/site.kg/stats/;
include /home/sitemarket/conf/web/site.kg.auth*;
}
include /etc/nginx/conf.d/phpmyadmin.inc*;
include /etc/nginx/conf.d/phppgadmin.inc*;
include /etc/nginx/conf.d/webmail.inc*;
include /home/sitemarket/conf/web/snginx.site.kg.conf*;
}