我正在尝试“CheckBot”,我有一个观察。问题是在我的PHP代码中我有一个if来检查URL是否存在于一个名为“seo_url”的表中,如果它不存在那么我们就会显示error.tpl的内容
# This program will keep
# bowling scores 'R'.
def game(bowling):
bowling_file = open('bowling.txt', 'r')
total = 0
NumLines = 0
line = bowling_file.readline()
while line != "":
NumLines += 1
bowling = int(line)
total += bowling
print(bowling)
line = bowling_file.readline()
average = total / NumLines
print('The average score for member #', count, sep='')
average = total / NumLines
def main():
game('bowling.txt')
main()
我发现,如果您在查找内容时输入example.com/page-not-fount,那么自“CheckBot”以来,这似乎不是正确的做法。
如何将错误页面设为错误404?
答案 0 :(得分:0)
http_response_code(404);
为了最佳实践。你应该这样回应它,让服务器(Apache / Nginx / IIS)处理404页面。