本文介绍了将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重定向到根目录(查询字符串除外)
发布评论