Help converting Apache HTACCESS directives to nginx?

st1905 nginx-forum at nginx.us
Sun Aug 22 18:55:50 MSD 2010


[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]

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,117689,122398#msg-122398




More information about the nginx mailing list