我今天修改了我的.htaccess文件的一些重写规则,如下所示:
这
RewriteRule ^about-us.php(.*)$ /about$1 [R=302,NC,L]
RewriteRule ^contact-us.php(.*)$ /service$1 [R=302,NC,L]
RewriteRule ^countertop-electrics/blenders(.*)$ /beverages/blenders [R=302,NC,L]
要
RewriteRule ^about-us.php(.*)$ /about [R=302,NC,L]
RewriteRule ^contact-us.php(.*)$ /service [R=302,NC,L]
RewriteRule ^countertop-electrics/blenders(.*)$ /beverages/blenders [R=302,NC,L]
目标是将产品页面(例如“countertop-electrics / blenders / product1234.html”)重定向到简单的类别页面,例如“饮料/搅拌机”,因为产品和类别的排序方式发生了变化。我通过降低$ 1或$来做到这一点,但现在似乎没有RewriteRules正在工作。我怎么能做到这一点?谢谢。
答案 0 :(得分:1)
在正则表达式中使用.+
:
RewriteRule ^about-us\.php.*$ /about [R=302,NC,L]
RewriteRule ^contact-us\.php.*$ /service [R=302,NC,L]
RewriteRule ^countertop-electrics/blenders.+$ /beverages/blenders [R=302,NC,L]
QUERY_STRING
将转移到新的URI。