Answer the question
In order to leave comments, you need to log in
How to set up rewrite in Nginx?
There is this config:
server {
server_name mysite.ru www.mysite.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/mysite.ru/*.conf;
access_log /var/www/httpd-logs/mysite.ru.access.log;
error_log /var/www/httpd-logs/mysite.ru.error.log notice;
set $root_path /var/www/mysite/data/www/mysite.ru;
root $root_path;
listen 185.220.35.79:80;
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
}
location @php {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@mysite.ru";
fastcgi_pass unix:/var/www/php-fpm/mysite.sock;
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
try_files $uri =404;
include fastcgi_params;
}
return 301 https://$host:443$request_uri;
}
server {
server_name mysite.ru www.mysite.ru;
ssl on;
ssl_certificate "/var/www/httpd-cert/mysite/mysite.ru_le1.crtca";
ssl_certificate_key "/var/www/httpd-cert/mysite/mysite.ru_le1.key";
ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
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/mysite.ru/*.conf;
access_log /var/www/httpd-logs/mysite.ru.access.log;
error_log /var/www/httpd-logs/mysite.ru.error.log notice;
set $root_path /var/www/mysite/data/www/mysite.ru;
root $root_path;
listen 185.220.35.79:443;
location / {
location ~ [^/]\.ph(p\d*|tml)$ {
try_files /does_not_exists @php;
}
}
location @php {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@mysite.ru";
fastcgi_pass unix:/var/www/php-fpm/mysite.sock;
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
try_files $uri =404;
include fastcgi_params;
}
add_header Strict-Transport-Security "max-age=31536000;";
}
rewrite ^/(.+)$ /redirect.php?get=$1 break;
Answer the question
In order to leave comments, you need to log in
location / {
try_files $uri $uri/ /redirect.php?get=$uri;
}
server {
listen 80;
server_name test.com
root /var/www/apps/test;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
try_files $uri =404;
}
}
server {
listen 80;
server_name test.com;
return 301 https://$host$request_uri;
}
<code>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question