Добрый день, Вы имеете в виду настройку сервера ?natalya писал(а):Добрый день! Можете ли вы предоставить конфиг реврайтов для Nginx?
natalya писал(а):Конфиг от симлы не подходит, выходит 500 ошибка. Помогите пожалуйста.
Ошибка 500 пропала, теперь косяк с фильтрами, выбрасывает 404 станицу.
natalya писал(а):Установлен Nginx, поддержка htaccess отсутствует. Нужен rewrite для products
Код: Выделить всё
server {
listen 80;
server_name site.ru www.site.ru;
root /var/www/site.ru/html;
index index.php;
client_max_body_size 64M;
access_log off;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location \.(txt|log)$ {
allow 192.168.0.0/16;
deny all;
}
location /backend {
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_ignore_client_abort on;
fastcgi_param SERVER_NAME $http_host;
}
}
rewrite ^/admin/?$ /backend last;
location ~* ^/(api|cache|compiled|config|design/(.*)/html|payment|Smarty|view)/(.*) { deny all; }
location / {
try_files $uri @rewrite;
}
location @rewrite {
rewrite ^/catalog/([^/]+)/?$ index.php?module=ProductsView&category=$1;
rewrite ^/catalog/([^/]+) index.php?module=ProductsView&category=$1;
rewrite ^/catalog/([^/]+)/([^/]+)/?$ index.php?module=ProductsView&category=$1&brand=$2;
rewrite ^/products/([^/]+)/?$ index.php?module=ProductView&product_url=$1;
rewrite ^/products/?$ index.php?module=ProductsView;
rewrite ^/all-products/?$ index.php?module=ProductsView;
rewrite ^/brands/([^/]+)/?$ index.php?module=ProductsView&brand=$1;
rewrite ^/brands/([^/]+)/page_([^/]+)/?$ index.php?module=ProductsView&brand=$1&page=$2;
rewrite ^/search/([^/]+)/?$ index.php?module=ProductsView&keyword=$1;
rewrite ^/search/?$ index.php?module=ProductsView;
rewrite ^/blog/([^/]+)/?$ index.php?module=BlogView&url=$1;
rewrite ^/blog/?$ index.php?module=BlogView;
rewrite ^/wishlist/([^/]+)/?$ index.php?module=WishlistView&id=$2&lang_label=$1;
rewrite ^/wishlist/?$ index.php?module=WishlistView&lang_label=$1;
rewrite ^/wishlist/delete/?$ index.php?module=WishlistView&id=$1&action=delete;
rewrite ^/comparison/?$ index.php?module=ComparisonView;
rewrite ^/cart/?$ index.php?module=CartView;
rewrite ^/cart/([^/]+)/?$ index.php?module=CartView&add_variant=$1;
rewrite ^/cart/remove/([^/]+)/?$ index.php?module=CartView&delete_variant=$1;
rewrite ^/order/([^/]+)/?$ index.php?module=OrderView&url=$1;
rewrite ^/order/?$ index.php?module=OrderView;
rewrite ^/user/login/?$ index.php?module=LoginView;
rewrite ^/user/register/?$ index.php?module=RegisterView;
rewrite ^/user/logout/?$ index.php?module=LoginView&action=logout;
rewrite ^/user/password_remind/?$ index.php?module=LoginView&action=password_remind;
rewrite ^/user/password_remind/([0-9a-z]+)/?$ index.php?module=LoginView&action=password_remind&code=$1;
rewrite ^/user/?$ index.php?module=UserView;
rewrite ^/sitemap.xml?$ sitemap.php last;
rewrite ^/yandex.xml?$ yandex.php last;
rewrite ^/contact/?$ index.php?module=FeedbackView;
rewrite ^/order/([^/]+)/([^/]+)/?$ index.php?module=OrderView&url=$1&file=$2;
if (!-f $request_filename){
set $rule_26 1$rule_26;
}
if (!-d $request_filename){
set $rule_26 2$rule_26;
}
if ($rule_26 = "21"){
rewrite ^/([^/]+)/?$ /index.php?module=PageView&page_url=$1;
}
rewrite ^/?$ /index.php?module=MainView&page_url=;
rewrite ^ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_ignore_client_abort on;
fastcgi_param SERVER_NAME $http_host;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
if (!-e $request_filename){
rewrite ^/files/products/(.+) /resize/resize.php?file=$1&token=$query_string;
}
}
}
Код: Выделить всё
session_start();
chdir('../../');
require_once('api/Okay.php');
$okay = new Okay();
natalya писал(а):Рабочий конфиг для NginxКод: Выделить всё
server {
listen 80;
server_name site.ru www.site.ru;
root /var/www/site.ru/html;
index index.php;
client_max_body_size 64M;
access_log off;
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location \.(txt|log)$ {
allow 192.168.0.0/16;
deny all;
}
location /backend {
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_ignore_client_abort on;
fastcgi_param SERVER_NAME $http_host;
}
}
rewrite ^/admin/?$ /backend last;
location ~* ^/(api|cache|compiled|config|design/(.*)/html|payment|Smarty|view)/(.*) { deny all; }
location / {
try_files $uri @rewrite;
}
location @rewrite {
rewrite ^/catalog/([^/]+)/?$ index.php?module=ProductsView&category=$1;
rewrite ^/catalog/([^/]+) index.php?module=ProductsView&category=$1;
rewrite ^/catalog/([^/]+)/([^/]+)/?$ index.php?module=ProductsView&category=$1&brand=$2;
rewrite ^/products/([^/]+)/?$ index.php?module=ProductView&product_url=$1;
rewrite ^/products/?$ index.php?module=ProductsView;
rewrite ^/all-products/?$ index.php?module=ProductsView;
rewrite ^/brands/([^/]+)/?$ index.php?module=ProductsView&brand=$1;
rewrite ^/brands/([^/]+)/page_([^/]+)/?$ index.php?module=ProductsView&brand=$1&page=$2;
rewrite ^/search/([^/]+)/?$ index.php?module=ProductsView&keyword=$1;
rewrite ^/search/?$ index.php?module=ProductsView;
rewrite ^/blog/([^/]+)/?$ index.php?module=BlogView&url=$1;
rewrite ^/blog/?$ index.php?module=BlogView;
rewrite ^/wishlist/([^/]+)/?$ index.php?module=WishlistView&id=$2&lang_label=$1;
rewrite ^/wishlist/?$ index.php?module=WishlistView&lang_label=$1;
rewrite ^/wishlist/delete/?$ index.php?module=WishlistView&id=$1&action=delete;
rewrite ^/comparison/?$ index.php?module=ComparisonView;
rewrite ^/cart/?$ index.php?module=CartView;
rewrite ^/cart/([^/]+)/?$ index.php?module=CartView&add_variant=$1;
rewrite ^/cart/remove/([^/]+)/?$ index.php?module=CartView&delete_variant=$1;
rewrite ^/order/([^/]+)/?$ index.php?module=OrderView&url=$1;
rewrite ^/order/?$ index.php?module=OrderView;
rewrite ^/user/login/?$ index.php?module=LoginView;
rewrite ^/user/register/?$ index.php?module=RegisterView;
rewrite ^/user/logout/?$ index.php?module=LoginView&action=logout;
rewrite ^/user/password_remind/?$ index.php?module=LoginView&action=password_remind;
rewrite ^/user/password_remind/([0-9a-z]+)/?$ index.php?module=LoginView&action=password_remind&code=$1;
rewrite ^/user/?$ index.php?module=UserView;
rewrite ^/sitemap.xml?$ sitemap.php last;
rewrite ^/yandex.xml?$ yandex.php last;
rewrite ^/contact/?$ index.php?module=FeedbackView;
rewrite ^/order/([^/]+)/([^/]+)/?$ index.php?module=OrderView&url=$1&file=$2;
if (!-f $request_filename){
set $rule_26 1$rule_26;
}
if (!-d $request_filename){
set $rule_26 2$rule_26;
}
if ($rule_26 = "21"){
rewrite ^/([^/]+)/?$ /index.php?module=PageView&page_url=$1;
}
rewrite ^/?$ /index.php?module=MainView&page_url=;
rewrite ^ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_ignore_client_abort on;
fastcgi_param SERVER_NAME $http_host;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
if (!-e $request_filename){
rewrite ^/files/products/(.+) /resize/resize.php?file=$1&token=$query_string;
}
}
}
В папке /backend/ajax удалить index.php и добавить во все файлыКод: Выделить всё
session_start();
chdir('../../');
require_once('api/Okay.php');
$okay = new Okay();
Код: Выделить всё
location ~* ^.+\.(png|jpg|jpeg|gif)$ {
if (!-e $request_filename){
rewrite ^/files/(.+)/(.*)$ /resize/resize.php?object=$1&file=$2&token=$query_string;
}
}
natalya писал(а):Рабочий конфиг для Nginx
В папке /backend/ajax удалить index.php и добавить во все файлыКод: Выделить всё
session_start();
chdir('../../');
require_once('api/Okay.php');
$okay = new Okay();
Код: Выделить всё
rewrite ^/backend/ajax/([^/]+)\.php$ /backend/ajax/index.php?file=$1 last;
Код: Выделить всё
nginx version: nginx/1.12.2
Код: Выделить всё
php -v
PHP 5.6.32 (cli) (built: Jan 23 2018 16:06:32)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
zyxer писал(а):не проверял, но все и так должно работать. Или что-то не работает?
Код: Выделить всё
RewriteRule ^([a-z]{2}/)?products/([^/]+)/?$ index.php?module=ProductView&product_url=$2&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?all-products/?$ index.php?module=ProductsView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?all-products/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=all-products [L,QSA]
RewriteRule ^([a-z]{2}/)?(discounted|bestsellers)/?$ index.php?module=ProductsView&lang_label=$1&mode=$2 [L,QSA]
RewriteRule ^([a-z]{2}/)?(discounted|bestsellers)/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=$2&mode=$2 [L,QSA]
Код: Выделить всё
server {
server_name nginx.starkbud.com.ua www.nginx.starkbud.com.ua;
charset off;
index index.php index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/nginx.starkbud.com.ua/*.conf;
access_log /var/www/httpd-logs/nginx.starkbud.com.ua.access.log;
error_log /var/www/httpd-logs/nginx.starkbud.com.ua.error.log notice;
ssi on;
return 301 https://$host:443$request_uri;
set $root_path /var/www/www-root/data/www/nginx.starkbud.com.ua;
root $root_path;
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 ~* ^.+\.(png|jpg|jpeg|gif)$ {
if (!-e $request_filename){
rewrite ^/files/(.+)/(.*)$ /resize/resize.php?object=$1&file=$2&token=$query_string;
}
}
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
expires max;
}
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@nginx.starkbud.com.ua";
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 @php {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@nginx.starkbud.com.ua";
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;
}
listen 185.197.163.8:80;
gzip on;
gzip_comp_level 6;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
}
server {
server_name nginx.starkbud.com.ua www.nginx.starkbud.com.ua;
ssl_certificate "/var/www/httpd-cert/www-root/nginx.starkbud.com.ua_le1.crtca";
ssl_certificate_key "/var/www/httpd-cert/www-root/nginx.starkbud.com.ua_le1.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 off;
index index.php index.html;
disable_symlinks if_not_owner from=$root_path;
include /etc/nginx/vhosts-includes/*.conf;
include /etc/nginx/vhosts-resources/nginx.starkbud.com.ua/*.conf;
access_log /var/www/httpd-logs/nginx.starkbud.com.ua.access.log;
error_log /var/www/httpd-logs/nginx.starkbud.com.ua.error.log notice;
ssi on;
set $root_path /var/www/www-root/data/www/nginx.starkbud.com.ua;
root $root_path;
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 ~* ^.+\.(png|jpg|jpeg|gif)$ {
if (!-e $request_filename){
rewrite ^/files/(.+)/(.*)$ /resize/resize.php?object=$1&file=$2&token=$query_string;
}
}
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
expires max;
}
location ~ \.php$ {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@nginx.starkbud.com.ua";
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 @php {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@nginx.starkbud.com.ua";
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;
}
listen 185.197.163.8:443 ssl;
gzip on;
gzip_comp_level 6;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
}
Код: Выделить всё
location ~* /(\w+/)?(\w+/)?(.+\.(jpg|jpeg|gif|png|webp|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf|woff|woff2|ttf|xls|xlsx|doc|docx|pdf))$ {
try_files $uri $uri/ /$2$3 /$3 /index.php?$args;
allow all;
access_log off;
expires max;
add_header Cache-Control public;
add_header Access-Control-Allow-Origin *;
}
Код: Выделить всё
"GET /ajax/cart_ajax.php?action=add_citem&variant_id=179&amount=1 HTTP/1.1" 404
Вернуться в «Предложения по улучшению OkayCMS»
Сейчас этот раздел просматривают: 22 гостя