WordPress htaccess 重定向 野生重定向 [英] WordPress htaccess redirect wild redirect

查看:60
本文介绍了WordPress htaccess 重定向 野生重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 WordPress WooCommerce.

I am using WordPress WooCommerce.

我的产品链接是这样的:http://example.com/product/tshirt123

My product links are like this: http://example.com/product/tshirt123

如何对 htaccess 进行编码,以便将我的链接重定向到 http://example2.com/product/tshirt123?

How do I code the htaccess so my links will be redirected to http://example2.com/product/tshirt123?

目前我的 htaccess 下面有这个代码,但它没有重定向http://example.com/product/tshirt123http://example2.com/product/tshirt123.

Currently I have this code below in my htaccess but it doesn't redirect http://example.com/product/tshirt123 to http://example2.com/product/tshirt123.

RewriteCond %{HTTP_HOST} ^example\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^product\/?(.*)$ "http\:\/\/example2\.com\/product$1" [R=301,L]

我应该如何更改以便重定向链接如下:

How should I change so it will redirect links like:

http://example.com/product/tshirt123http://example2.com/product/tshirt123?

推荐答案

只需将此添加到.htaccess"文件的顶部,而不是在 WordPress 默认规则之后.

Just add this to the top of your '.htaccess' file and NOT after WordPress default rules.

RewriteEngine On
RewriteRule ^(product)/(.*)$ http://example2.com/product/$2 [R=301,L]

这篇关于WordPress htaccess 重定向 野生重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆