我正在尝试重定向
http://www.example.com/shop/childrens-shinnerz-by-size/extra-small
至
http://www.example.com/sports-goods/childrens-shinnerz/all-extra-small-5-7-yrs
这样
Redirect 301 /shop/childrens-shinnerz-by-size/extra-small /sports-goods/childrens-shinnerz/all-extra-small-5-7-yrs
但它重定向到错误的url
http://www.example.com/sports-goods/childrens-shinnerz/extra-small
因此部分all-
和-5-7-yrs
被忽略。
如何重定向到正确的URL?
使用这个,它应该可以工作:
RedirectMatch 301 http://www.example.com/shop/childrens-shinnerz-by-size/extra-small(.*) http://www.example.com/sports-goods/childrens-shinnerz/all-extra-small-5-7-yrs/$1
来源:http://www.htaccessredirect.net/
如果您在站点的根目录中使用.htaccess文件,
RewriteRule ^shop/childrens-shinnerz-by-size/extra-small(.*)$ http://www.example.com/sports-goods/childrens-shinnerz/all-extra-small-5-7-yrs/$1 [R=301,NC,L]
我找到了的方法
RedirectMatch 301 ^/shop/childrens-shinnerz-by-size/extra-small$ /sports-goods/childrens-shinnerz/all-extra-small-5-7-yrs
这正是我想要的
我在服务器上测试过它,它运行良好
http://www.familybmi.com/shop/childrens-shinnerz-by-size/extra-small
也许你的apache有问题,试着测试之类的其他东西
Redirect 301 /retiredpage.html http://www.example.com/newpage.html
如果你没有得到想要的结果,那就意味着你可能需要更新你的apache