php - Nginx rewrite some matching rules are not working -


i want move these working rules

location = /contact {   rewrite ^(.*)$ /index.php?v=contact last; break; }  location = /terms {   rewrite ^(.*)$ /index.php?v=terms last; break; }  location = /faq {   rewrite ^(.*)$ /index.php?v=faq last; break; }  location = /twitter {   rewrite ^(.*)$ /index.php?v2=twitter last; break; }  location = /facebook {   rewrite ^(.*)$ /index.php?v2=facebook last; break; }  location = /login {   rewrite ^(.*)$ /index.php?v2=login last; break; }  location = /privacy {   rewrite ^(.*)$ /index.php?v=privacy last; break; } 

to this

location / {   try_files $uri $uri/ =404;   rewrite ^/(contact|privacy|terms|faq)$ /index.php?v=$1 last;   rewrite ^/(twitter|facebook|login)$ /index.php?v2=$1 last; break; } 

but thing 'contact','terms','privacy','twitter','facebook' pages working correctly 'privacy' , 'login' pages throwing 404 error.

there no other rewrite rules involving 'login' , 'privacy'

actually don't neither of methods, might working it's not best way write it, lets try different.

location *~ ^/(contact|privacy|terms|faq)/?$ {     try_files $uri $uri/ /index.php?v=$1; } location *~ ^/(twitter|facebook|login)/?$ {     try_files $uri $uri/ /index.php?v2=$1; } location / {     try_files $uri $uri/ /index.php; } 

o , never heard of last; break; it's working because nginx ignoring last part of it, it's either last or break,


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -