php如果让/index.php后面所有的链接都返回到首页?

小黑帽子 2019-03-07 06:09:56
http://www.szim.net.cn/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?
...全文
338 4 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
下雨的声音丶 2019-03-08
  • 打赏
  • 举报
回复
RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule ^index.php.*$ / [R=301,L] 这样呢
小黑帽子 2019-03-08
  • 打赏
  • 举报
回复
引用 1 楼 下雨的声音丶 的回复:
试一试把
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^index.php.*$ index.php



不行喽,没效果;
小黑帽子 2019-03-08
  • 打赏
  • 举报
回复
引用 3 楼 下雨的声音丶 的回复:
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^index.php.*$ / [R=301,L]
这样呢

嗯,这样301跳转的确可以,谢谢了.
下雨的声音丶 2019-03-07
  • 打赏
  • 举报
回复
试一试把 RewriteCond %{QUERY_STRING} ^(.*)$ RewriteRule ^index.php.*$ index.php

20,398

社区成员

发帖
与我相关
我的任务
社区描述
“超文本预处理器”,是在服务器端执行的脚本语言,尤其适用于Web开发并可嵌入HTML中。PHP语法利用了C、Java和Perl,该语言的主要目标是允许web开发人员快速编写动态网页。
phpphpstorm 技术论坛(原bbs)
社区管理员
  • 开源资源社区
  • phpstory
  • xuzuning
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧