【发布时间】:2015-01-15 07:42:11
【问题描述】:
我在输入时不断收到 404 错误。
localhost/shirt.php?id= 后跟我创建的数组中的一个数字
RewriteEngine On
RewriteRule ^shirts/$ /shirts/shirts.php
RewriteRule ^shirts/([0-9]+)/$ /shirts/shirt.php?id=$1
RewriteRule ^receipt.php$ /receipt/ [R=301]
RewriteRule ^contact.php$ /contact/ [R=301]
RewriteRule ^shirts.php$ /shirts/ [R=301]
RewriteCond %{QUERY_STRING} ^id=([0-9]+)$
RewriteRule ^shirt.php$ /shirt/%1/? [R=301]
在 Chrome 中使用 MAMP,我已经多次清除缓存
【问题讨论】:
-
啊,
301 Moved Permanently的快乐!在你真正关闭浏览器并重新打开它之前,你会很开心(即使那样仍然可能)。在开发过程中,你永远不应该使用[R=301],因为浏览器缓存会非常激进地重定向。 -
这是你想要发生的事情:
localhost/shirt.php?id=在浏览器中请求,RewriteRule ^shirt.php$ /shirt/%1/? [R=301]被匹配,301'ed 到RewriteRule ^shirts/([0-9]+)/$ /shirts/shirt.php?id=$1?如果是这样,您没有规则来捕获新 URL -
你想做什么?您想在浏览器中显示哪些 URL,哪些应该是内部 URL?
-
@Boldewyn 刚刚关闭了 chrome 重新打开了另一个 404
-
@anubhava 我的目标是像 localhost/shirt/101 这样的东西,但在我的本地服务器上它看起来像 local/shirt.php?id= 数组中的任何东西