我有products.php,我试图改变成/ europe-cell-phone /。 我做了一个重写规则来做到这一点:
RewriteRule ^europe-cell-phone/$ products.php [L]
但是,我也需要301旧页面(products.php)到/ europe-cell-phone /。 我试图用以下规则来做到这一点:
RewriteRule ^products.php$ http://www.eurobuzz.com/europe-cell-phone/ [R=301,L]
然而,当然,当我去products.php期待被redirect,我打了一个无限的redirect循环,有没有解决这个问题? 以前从未遇到过这个问题。
您需要将您的products.php重命名为products-new.php并创build如下两个规则:
RewriteRule ^ europe-cell-phone / $ products-new.php [L]
RewriteRule ^ products.php $ products-new.php [R = 301,L]
您需要在THE_REQUESTtesting原始请求,因为REQUEST_URI可能已经被规则更改过了:
RewriteCond %{THE_REQUEST} ^[AZ]+\ /products\.php RewriteRule ^products\.php$ /europe-cell-phone/ [R=301,L] RewriteRule ^europe-cell-phone/$ products.php [L]
在Apache中重写,你写这样的:RewriteRule 模式 replace
因此,您列出的第一条规则与“europe-cell-phone”相匹配,并用“products.php”代替
你的第二条规则似乎恰恰相反。 我想你可能需要在你的第一条规则中切换。