问题
I am using WordPress WooCommerce.
My product links are like this: http://example.com/product/tshirt123
How do I code the htaccess
so my links will be redirected to http://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/tshirt123
to
http://example2.com/product/tshirt123
?
回答1:
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]
来源:https://stackoverflow.com/questions/51451001/wordpress-htaccess-redirect-wild-redirect