我已经更改了wordpress的域,只想重定向EC页面。域是示例。
・Old Domain -> https://old-domain.com
・New Domain -> https://new-domain.com
我想将所有页面从旧页面重定向到新页面,除了这些页面。
・shop
・product
・cart
・checkout
我把这些写在我的htaccess文件中。
▼旧域名(只想将商店、产品、购物车、结帐目录重定向到新域名。
RewriteEngine on
RewriteBase /
RewriteRule ^shop(.*)$ https://new-domain.com/shop$1 [R=301,L]
RewriteRule ^product(.*)$ https://new-domain.com/product$1 [R=301,L]
RewriteRule ^cart(.*)$ https://new-domain.com/cart$1 [R=301,L]
RewriteRule ^checkout(.*)$ https://new-domain.com/checkout$1 [R=301,L]
▼新域名(希望将所有页面重定向到旧域名,摘录商店,产品,购物车,结帐目录。
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/shop/$
RewriteCond %{REQUEST_URI} !^/product/$
RewriteCond %{REQUEST_URI} !^/cart/$
RewriteCond %{REQUEST_URI} !^/checkout/$
RewriteRule (.*) https://old-domain.com [R=301,L]
它们都不起作用。它似乎在一会儿正确重定向,但立即回到https://new-domain.com。 请帮我解决它。
我刚刚自己解决了! 以上是我在httaccess文件上写的正确答案。
▼old-domain.com
RewriteEngine on
RewriteBase /
RewriteRule ^shop(.*)$ https://new-domain.com/shop$1 [R=301,L]
RewriteRule ^product(.*)$ https://new-domain.com/product$1 [R=301,L]
RewriteRule ^cart(.*)$ https://new-domain.com/cart$1 [R=301,L]
RewriteRule ^checkout(.*)$ https://new-domain.com/checkout$1 [R=301,L]
▼new-domain.com
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !(^/shop/)
RewriteCond %{REQUEST_URI} !(^/product/)
RewriteCond %{REQUEST_URI} !(^/cart/)
RewriteCond %{REQUEST_URI} !(^/checkout/)
RewriteCond %{REQUEST_URI} !(^/checkout/order-received/)
RewriteRule ^$ https://old-domain.com/ [R=301,L]