K
K
ktonado2017-07-11 18:05:23
Nginx
ktonado, 2017-07-11 18:05:23

nginx settings - redirect to www, how to exclude circular redirect?

stuck with a redirect from a domain without vbb to a domain with vbb
server
{
listen 80;
server_name www.mfxxx.ru;
return 301 $scheme://www.mfxxx.ru$request_uri;
rewrite ^/(.*)/$ /$1 permanent;
charset utf-8;
allow all;
root /home/mg/mfxxx.ru/public;
index index.php index.html;
set $app_root /home/mg/mfxxx.ru/public;
if ($request_uri ~* "^(.*/)index\.php$") {
return 301 $1;
}
location ~* \.(svg|jpg|jpeg|js|gif|png|ico|css|bmp|swf|woff|woff2|tar\.gz|html|pdf|doc|docx|xls|xlsx)$ {
root $app_root;
expires max;
add_header Cache-Control "public";
}
location /
{
try_files $uri $uri/ /index.php?$args;
include fastcgi_params;
fastcgi_intercept_errors On;
fastcgi_connect_timeout 60;
fastcgi_read_timeout 60;
fastcgi_pass mg;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
rewrite ^([^.]*[^/])$ $1/ permanent;
}
#give all files not ending with php
location ~* '^/.+\.\w{2,5}(?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
zooks, 2017-07-11
@zooks

No rewrite to redirect from a domain!

server {
    listen       80;
    server_name  www.example.org;
    return       301 http://example.org$request_uri;
}

nginx.org/en/docs/http/converting_rewrite_rules.html

T
TyzhSysAdmin, 2017-07-11
@POS_troi

Because these should be two different sections
of the config 1st configured on mfxxx.ru and a redirect on www.mfxxx.ru
2nd is the main config of the virtual host www.mfxxx.ru

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question