将index.php重定向到根目录(查询字符串除外)

编程入门 行业动态 更新时间:2024-10-19 19:40:10
本文介绍了将index.php重定向到根目录(查询字符串除外)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个旧网站,需要在其中将index.php重定向到根目录以防止重复内容。通常,我会使用以下内容:

I have an old website where I need to redirect index.php to the root to prevent duplicate content. Normally I'd use the following:

RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php RewriteRule ^index\.php$ / [L,R=301]

问题是,我有一些页面,例如index.php?id = 6,index.php?id = 14,我不想重定向到根目录。

The problem is, I have some pages such as index.php?id=6, index.php?id=14 that I don't want redirecting to the root.

如何修改上述.htaccess规则以排除包含这些查询字符串的index.php文件?

How could I amend the above .htaccess rule to exclude index.php files that contain these query strings?

谢谢,

利亚姆

推荐答案

您可以在 RewriteRule之前添加:

RewriteCond %{QUERY_STRING} ^$

更多推荐

将index.php重定向到根目录(查询字符串除外)

本文发布于:2023-11-01 02:09:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1547942.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:根目录   字符串   重定向   index   php

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!