删除一块 url 并在新位置插入另一块

Remove a piece of url and insert another piece in a new position

我正在尝试更改此网址::

www.example.it/ mio-pezzo- product-1-url.html --> www.example.com/product-1- my-piece- url.html
www.example.com/product-1- my-piece- url.html --> www.example.it/ mio-pezzo- product-1-url.html

我试过这样的事情:

RewriteCond %{HTTP_HOST} ^(.*)\.it$ [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^(.*)my-piece-(.*)$ /mio-pezzo- [L,R=301]

RewriteCond %{HTTP_HOST} ^(.*)\.com$ [NC]
RewriteCond %{HTTPS}s ^on(s)|
RewriteRule ^(.*)mio-pezzo-(.*)$ /my-piece- [L,R=301]

但这是结果...

www.example.it/ mio-pezzo- product-1-url.html --> www.example.com/ my-piece- product-1-url.html
www.example.com/product-1- my-piece- url.html --> www.example.it/product-1- mio-pezzo- url.html

如何将它移动到之后或之前?

只需在第一个 RewriteRule 上的 mio-pezzo- 之后移动 </code>,如下所示:</p> <pre><code>RewriteCond %{HTTP_HOST} ^(.*)\.it$ [NC] RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^(.*)my-piece-(.*)$ /mio-pezzo- [L,R=301] RewriteCond %{HTTP_HOST} ^(.*)\.com$ [NC] RewriteCond %{HTTPS}s ^on(s)| RewriteRule ^(.*)mio-pezzo-(.*)$ /my-piece- [L,R=301]