server {
listen 80;
server_name www.test.ru;
return 301 http://test.ru$request_uri;
}
server {
listen 80;
server_name test.ru;
root /gopanel/sites/www_test_tu/www;
index index.html index.htm index.php index.cgi index.pl index.xhtml;
location ~ /\. { internal; }
location / { rewrite ^([^.\?]*[^/])$ $1/ permanent; }
location /odminka/ { }
location /guide { }
try_files $uri $uri/ /index.php/$uri;
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
}
}
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
# RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# Redirect to www
RewriteCond %{REQUEST_URI} !robots\.txt$
RewriteCond %{HTTP_HOST} !^www [NC]
RewriteRule .* http://www.%{HTTP_HOST}/$0 [R=301,L]
# Redirect urls with no trailing slash
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/cm/
RewriteCond %{REQUEST_URI} !^/guide
RewriteCond %{REQUEST_URI} !\.xml$
RewriteCond %{REQUEST_URI} !\.txt$
RewriteCond %{REQUEST_URI} !/$
RewriteRule .+ $0/ [R=301,L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
AddDefaultCharset utf-8
#redirect to www start
server {
listen 80;
server_name test.ru;
return 301 $scheme://www.test.ru$request_uri;
}
#end
server {
listen 80;
root /gopanel/sites/www_test_tu/www;
index index.php;
server_name www.test.ru;
location ~ /\. { internal; }
rewrite ^([^.\?]*[^/])$ $1/ permanent;
try_files $uri $uri/ /index.php/$uri;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param HTTP_PROXY "";
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
fastcgi_intercept_errors on;
}
}
#redirect to www start
server {
listen 80;
server_name test.ru;
return 301 $scheme://www.test.ru$request_uri;
}
#end
server {
listen 80;
root /gopanel/sites/www_test_tu/www;
index index.php;
server_name www.test.ru;
# Prevent access to hidden files
location ~ /\. {
deny all;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param HTTP_PROXY "";
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_split_path_info ^(.+?\.php)(/.+)$;
}
#Deny access to Git catalog
location ~ /.git/ {
deny all;
}
#Защититься от запросов к несуществующим файлам
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
error_page 404 /404.html;
#my 404
location = /404.html {
root /gopanel/sites/www_test_tu/www;
internal;
}
}