M
M
Maxim Timofeev2015-12-27 15:00:35
Nginx
Maxim Timofeev, 2015-12-27 15:00:35

How to set up NGINX to redirect to the mobile version?

With nginx, not even on "you", practically unfamiliar.
Actually found the solution on the Internet. but I do not quite understand how to connect it with what I have. I will be glad to hints, solutions and links to tutorials too.
Here is my code (not mine, but the isp socket gene):

#user 'wokster' virtual host 'мойдомен.ru' configuration file
server {
  server_name мойдомен.ru www.мойдомен.ru;
  charset UTF-8;
  disable_symlinks if_not_owner from=$root_path;
  index index.html index.php;
  root $root_path;
  set $root_path пути;
  access_log пути;
  error_log пути
  include пути*.conf;
  location / {
    location ~* ^.+\.(jpg|jpeg|gif|png|svg|js|css|mp3|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
      try_files $uri $uri/ @fallback;
    }
    location / {
      try_files /does_not_exists @fallback;
    }
    location ~ [^/]\.ph(p\d*|tml)$ {
      try_files /does_not_exists @fallback;
    }
  }
  location @fallback {
    proxy_pass http://127.0.0.1:8080;
    proxy_redirect http://127.0.0.1:8080 /;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    access_log off ;
  }
  ssi on;
  listen ipмоего сервера:80;
}

Here is the code that should solve the problem:
server{ < … >	if ( $http_user_agent ~* (windows\smobile|windows\sce|iphone|ipod|midp|symbian|series\s60|s60|nokia|аndroid| blackberry) ){ rewrite ^/(.*) http://m.site.ru/$1 permanent; } location / { < … > } }

taken from here: habrahabr.ru/post/108242
I don’t understand where to insert it and what is "< … >"?
If someone can put this together I'd be grateful. I can like it to death or write a review, where you specify.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
romy4, 2015-12-27
@romy4

my modesty does not allow such a genius to give clues

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question