.htaccess 如何使用RewriteCond消除重复页面

.htaccess 如何使用RewriteCond消除重复页面,.htaccess,.htaccess,大家好!我需要一些关于htaccess的帮助,因为我真的被它困住了。我有一些页面,如: site.ru/books site.ru/pens 这些链接可以被其他URL调用: site.ru/index.php?show=books site.ru/index.php?show=pens 我希望你明白上面的链接是平等的。只是,URL是用户友好的 我想使用RewriteCond将“site.ru/index.php?show=books”重定向到“site.ru/books”,因为Google或其他

大家好!我需要一些关于htaccess的帮助,因为我真的被它困住了。我有一些页面,如:

site.ru/books

site.ru/pens

这些链接可以被其他URL调用:

site.ru/index.php?show=books

site.ru/index.php?show=pens

我希望你明白上面的链接是平等的。只是,URL是用户友好的

我想使用RewriteCond将“site.ru/index.php?show=books”重定向到“site.ru/books”,因为Google或其他搜索引擎不喜欢重复页面


但问题是我不知道怎么写……请帮帮我,对不起我的英语不好;-)

将此代码放入您的
文档\u ROOT/.htaccess
文件:

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} \s/+index\.php\?show=([^\s&]+) [NC]
RewriteRule ^ %1? [R=302,L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/?$ index.php?show=$1 [L,QSA]