【发布时间】:2018-06-28 17:36:19
【问题描述】:
我在重定向不存在的目录(或者可能是 php 包含)时遇到问题。
例子:
-
正确路径:
olafernst.com/shooting.php = 很好
php 中的错字:
olafernst.com/xxshooting.php = 很好 (404 redirect)
- php 中的错字和不存在的目录:
olafernst.com/xxshooting.php/nonexistfolder = 很好 (404 redirect)
- 路径正确但目录不存在:
olafernst.com/shooting.php/nonexistfolder = 返回:
状态码200 insted of 404 找不到包含的php。
有什么想法吗?
谢谢
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<html lang="en-EN">
<head>
<meta charset="utf-8">
<title>Olaf Ernst Photography</title>
<meta name="description" content="Olaf Ernst captures beautiful nature and stunning portraits with decades of experience. Visit to see for yourself. Landscapes, Portraits, Cities, Urban, Nudes.">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="copyright" content="Olaf Ernst Photography">
<meta name="msvalidate.01" content="8FC8C224898F3874EAA240BA4B1E6133" />
<link rel="shortcut icon" href="favicon.ico">
<!-- plugins' css -->
<link rel="stylesheet" href="css/plugins.css">
<!-- google fonts -->
<link href='https://fonts.googleapis.com/css?family=Oswald:400,700,300%7cPoppins:400,300,500,700,600' rel='stylesheet' type='text/css'>
<!-- main css file -->
<link rel="stylesheet" href="css/main.css">
<!-- modernizr -->
<script src="js/lib/modernizr-2.6.2.min.js"></script>
</head>
<body>
</body>
</html>
【问题讨论】:
-
如何收录?你能分享你的代码吗?
-
像这样:
-
我仍然没有看到任何代码,也不明白你是如何做到这一点的:“olafernst.com/shooting.php/nonexistfolder”
-
也许我不想正确描述这个问题。如果您在浏览器中输入了错误的 URL,菜单将无法正确显示。我预计不存在的目录会出现 404 错误。我检查了返回状态,它是 200 而不是 404。所有重定向都按预期工作。只有目录名称错误的那些不起作用。你要我分享什么代码?
-
你使用一些 .htaccess 规则吗?您如何将脚本名称从 url 翻译为包含?你可能使用 $_SERVER["PHP_SELF"] 吗?
标签: php .htaccess redirect http-status-code-404