S
S
sandrain2014-08-11 14:15:25
Nginx
sandrain, 2014-08-11 14:15:25

how to do nginx mobile rewrite

Making a proxy for the mobile version

server {
  listen 80;
  server_name m.example.com;
 location / {
    proxy_pass http://example.com/mobile/;
    proxy_redirect     off;
    proxy_set_header   Host example.com; 
 }
}

so all my links become m.example.com/mobile/mycoolurl
how to remove this /mobile?
......
 location / {
    rewrite /mobile(.*) /$1 break;
    proxy_pass http://example.com/mobile/;
    proxy_redirect     off;
    proxy_set_header   Host example.com; 
 }

tried different rewrites...nothing

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question