Help converting Apache HTACCESS directives to nginx?

Igor Sysoev igor at sysoev.ru
Sun Aug 22 22:07:19 MSD 2010


On Sun, Aug 22, 2010 at 10:55:50AM -0400, st1905 wrote:

> [code]
> if ($http_host ~ "^www.domain.com"){
> 	set $rule_0 1$rule_0;
> }
> if ($rule_0 = "1"){
> 	rewrite /(.*) http://domain.com/$1 permanent;
> 	break;
> }
> if ($http_host ~ "^beta.domain.com"){
> 	set $rule_1 1$rule_1;
> }
> if ($rule_1 = "1"){
> 	rewrite /(.*) http://domain.com/$1 permanent;
> 	break;
> }
> if (!-f $request_filename){
> 	set $rule_2 1$rule_2;
> }
> if (!-d $request_filename){
> 	set $rule_2 2$rule_2;
> }
> if (!-f $document_root/$1.php){
> 	set $rule_2 3$rule_2;
> }
> if (-f $document_root/msg.html){
> 	set $rule_2 4$rule_2;
> }
> if ($rule_2 = "4321"){
> 	setenv ${escapemap:$1}&template;
> 	rewrite ^/([a-z0-9_\-@#\ /"'\+]+)/?([a-z0-9_\-]+)?(\.png|/)?$;
> }
> if ($uri !~ "/msg.html$"){
> 	set $rule_3 1$rule_3;
> }
> if ($uri !~ "/generation/image.php$"){
> 	set $rule_3 2$rule_3;
> }
> #ignored: condition 2
> #ignored: condition 3
> if (-f $document_root/msg.html){
> 	set $rule_3 5$rule_3;
> }
> if ($rule_3 = "541"){
> 	rewrite /$ /msg.html last;
> }
> #ignored: condition 0
> 	rewrite ^/(index|index\.php)$ http://domain.com/ permanent;
> 	break;
> if (-f $document_root/$1.php){
> 	set $rule_5 1$rule_5;
> }
> if ($rule_5 = "1"){
> 	rewrite ^/(.*)$ /$1.php last;
> }
> if (-f $document_root/$1.php){
> 	set $rule_6 1$rule_6;
> }
> if ($rule_6 = "1"){
> 	rewrite ^/(.*)/$ http://domain.com/$1 permanent;
> 	break;
> }
> #ignored: condition 0
> if (-f $document_root/$1.php){
> 	set $rule_7 2$rule_7;
> }
> if ($rule_7 = "21"){
> 	rewrite ^/([^.]+)\.php$ http://domain.com/$1 permanent;
> 	break;
> }
> #ignored: condition 0
> #ignored: condition 1
> 	setenv ${escapemap:$1}&template;
> 	rewrite ^/([a-z0-9_\-@#\ /"'\+]+)/?([a-z0-9_\-]+)?(\.png|/)?$;
> 
> [/code]

No, you should not use this sendmail style configuration.
However, I do not understand what the original htaccess should do.


-- 
Igor Sysoev
http://sysoev.ru/en/



More information about the nginx mailing list