I use nginx in ispconfig 3 panel The vhost are like this Code: server { listen *:80; server_name domain.com www.domain.com sub.domain.com; root /var/www/domain.com/web; if ($http_host = "sub.domain.com") { rewrite ^(?!/\b(ar|stats|error)\b)/(.*)$ /sub/$2 ; } index index.html index.htm index.php index.cgi index.pl index.xhtml; rewrite ^/contactez-nous /contact.php break; error_page 400 /error/400.html; error_page 401 /error/401.html; error_page 403 /error/403.html; error_page 404 /error/404.html; error_page 405 /error/405.html; error_page 500 /error/500.html; error_page 502 /error/502.html; error_page 503 /error/503.html; recursive_error_pages on; location = /error/400.html { ... I want to add an rewrite rule in sub.domain.com I try this, but do not work Code: if ($http_host = "sub.domain.com") { rewrite ^(?!/\b(ar|stats|error)\b)/(.*)$ /sub/$2 ; rewrite ^/contactez-nous /contact.php break; } Does any one have an idea?
Try to exchange the order of the rewrite lines to: rewrite ^/contactez-nous /contact.php break; rewrite ^(?!/\b(ar|stats|error)\b)/(.*)$ /sub/$2 ;
This work, thank you, but we must add /sub befor contact.php, like this rewrite ^/contactez-nous /sub/contact.php break; rewrite ^(?!/\b(ar|stats|error)\b)/(.*)$ /sub/$2 ;
Ok. The reason is that the first rewrite has been processed already so probably this should work as well: rewrite ^(?!/\b(ar|stats|error)\b)/(.*)$ /sub/$2 ; rewrite ^/sub/contactez-nous /sub/contact.php break; But I would leave it in the reverse order.