【发布时间】:2012-05-15 02:52:57
【问题描述】:
我有一些网页具有以下 URL 结构:
/details/id/125/
由于某种原因,Google 已将看起来像 /details/125/ 的页面编入索引,而 /id/ 部分缺失。这会导致重复的内容问题。
所以我需要一个 .htaccess RedirectMatch 规则,以便如果 URL 包含 /details/ 但之后不包含 /id/,则重定向到 404 页面。
到目前为止我没有任何运气的尝试:
重定向匹配 404 ^/details/(?!id)/
在我的研究中,我发现了此信息 http://www.mycomputingart.com/programming/Z24.regexpadv.html,我认为这与我需要做的事情有关,但我无法理解它。
【问题讨论】:
-
这也可能对你有用:support.google.com/webmasters/bin/…
-
谢谢。不幸的是,对于我的特殊情况,我需要使用 htaccess 来完成。
标签: regex .htaccess negative-lookahead