【发布时间】:2011-12-20 19:06:22
【问题描述】:
任何人都可以帮助解决 .htaccess URL 重写规则。
我需要像这样重定向页面:
www.website.com/index.php?a=some-word-some-other-word
www.website.com/index.php?a=something
www.website.com/index.php?a=some-other-thing
所有这些页面的内容都与 www.website.com/index.php 相同
到
www.website.com/index.php 或 www.website.com/
我已经问过了,我得到了这个:
RewriteEngine On
RewriteBase /
#if the query string has an a parameter
RewriteCond %{QUERY_STRING} (^|&)a= [NC]
#Redirect and remove query string parameters
RewriteRule .* http://www.website.com/? [R=301,L]
这样做,它将这些页面重定向到主页(站点的根目录)。但我有一些网页的网址如下:
i.php?a=something-something-something
问题是上面的 .htaccess 代码也会影响这些链接。
任何人都可以编写该代码来重定向基于index.php?a=的页面链接而不是也用于i.php?a=。
【问题讨论】: