我只想將根頁面從 1 個子域域重定向到另一個域,例如:從https://checkout.example.com到https://www.example.com/index.php?route=checkout/cart/
但是,所有其他頁面和帶有 $ 和 & 的查詢字串應該保持不變。例如: https ://checkout.example.com/?Amount=1899&Invoice=55498213 應該保持原樣
我嘗試了多個 htaccess 規則文本:Redirect 301、Redirect、RedirectMatch、RewriteRule。所有規則都使用查詢字串重定向域。
這是我當前的 .htaccess 規則
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteRule ^$
RewriteCond %{HTTP_HOST} ^checkout\.example\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/index.php?route=checkout/cart/ [L,R=301]
</IfModule>
uj5u.com熱心網友回復:
這應該適合你:
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{REQUEST_URI} ^/$
RewriteCond %{HTTP_HOST} ^checkout\.domain1\.com$ [NC]
RewriteRule .* https://www.domain2.com/checkout [L,R=301]
uj5u.com熱心網友回復:
這終于奏效了,添加到 .htaccess 檔案的頂部
RewriteEngine On
RewriteCond %{QUERY_STRING} ^$
RewriteCond %{HTTP_HOST} ^checkout\.example\.com$ [NC]
RewriteRule ^(.*)$ https://www.example.com/index.php?route=checkout/cart/ [L,R=301]
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/426046.html
