小黑帽子 2019-03-07 17:07 采纳率: 50%
浏览 1029
已采纳

php如果让/index.php后面所有的链接都返回到首页?伪静态规则问题

http://demo.phpmywind.com/index.php/common/productdetail/id/12.html

这个链接本来应该是不存在的,但是做网站的时候百度偏偏收录了这个链接,怎么让/index.php/common/productdetail/id/12.html这样的链接直接是打开的是首页啊?
/common/productdetail/id/ 都是不存在的目录,只有在index.php/后面加不存在的目录都能打开乱的页面,比如:http://demo.phpmywind.com/index.php/c000/
这个是伪静态规则写的问题吗?
伪静态规则附上:
.htaccess文件如下:

# 将 RewriteEngine 模式打开
RewriteEngine On

# 修改以下语句中的 / 改为您的系统目录地址,如果程序放在根目录中则无需修改
RewriteBase /

RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^index.html$ index.php
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^about-([0-9]+)-([0-9]+)\.html$ about.php?cid=$1&page=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^news-([0-9]+)-([0-9]+)\.html$ news.php?cid=$1&page=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^newsshow-([0-9]+)-([0-9]+)-([0-9]+)\.html$ newsshow.php?cid=$1&id=$2&page=$3
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^product-([0-9]+)-([0-9]+)\.html$ product.php?cid=$1&page=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^productshow-([0-9]+)-([0-9]+)-([0-9]+)\.html$ productshow.php?cid=$1&id=$2&page=$3
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^case-([0-9]+)-([0-9]+)\.html$ case.php?cid=$1&page=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^caseshow-([0-9]+)-([0-9]+)-([0-9]+)\.html$ caseshow.php?cid=$1&id=$2&page=$3
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^join-([0-9]+)\.html$ join.php?page=$1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^joinshow-([0-9]+)\.html$ joinshow.php?id=$1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^message-([0-9]+)\.html$ message.php?page=$1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^contact-([0-9]+)-([0-9]+)\.html$ contact.php?cid=$1&page=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^soft-([0-9]+)-([0-9]+)\.html$ soft.php?cid=$1&page=$2
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^softshow-([0-9]+)-([0-9]+)-([0-9]+)\.html$ softshow.php?cid=$1&id=$2&page=$3
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^goods-([0-9]+)-([0-9]+)-([0-9]+)\.html$ goods.php?cid=$1&tid=$2&page=$3
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^goodsshow-([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\.html$ goodsshow.php?cid=$1&tid=$2&id=$3&page=$4
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^vote-([0-9]+)\.html$ vote.php?id=$1
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(\w+)\.html$ $1.php?
  • 写回答

1条回答 默认 最新

  • 听楼一夜雨 2019-03-07 17:11
    关注

    你的首页链接写的是index.php,导致收录的其他页面的首页出现相对目录,最好在路径前面加个/

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 已采纳回答 8月10日