agn has asked for the wisdom of the Perl Monks concerning the following question:
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem with if condition
by Corion (Patriarch) on Jul 13, 2009 at 09:30 UTC | |
by agn (Initiate) on Jul 13, 2009 at 09:53 UTC | |
|
Re: problem with if condition
by Bloodnok (Vicar) on Jul 13, 2009 at 12:01 UTC |