The problem is that whether the $DOCROOT.$uri contains a / at the end or not, it always sets $status_code to 301.my $DOCROOT = '/home/agn/htdocs'; if (-e $DOCROOT.$uri) { if (-f $DOCROOT.$uri) { if (-r $DOCROOT.$uri) { logme("200 HTTP OK\n"); $status_code = 200; } else { logme("403 Forbidden\n"); $status_code = 403; } } elsif (-d $DOCROOT.$uri) { if (-r $DOCROOT.$uri && -x $DOCROOT.$uri && ($DOCROOT.$uri !~ /\/$/)) { logme("301 Moved Permanently\n"); $status_code = 301; } elsif (-r $DOCROOT.$uri && -x $DOCROOT.$uri) { logme("200 HTTP OK\n"); $status_code = 200; } else { logme("403 Forbidden\n"); $status_code = 403; } } else { logme("406 Not Acceptable\n"); $status_code = 406; } } else { logme("404 Not Found\n"); $status_code = 404; } } return 0; }
In reply to problem with if condition by agn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |