我正在嘗試通過 htaccess 將所有帶有特定單詞的 url 重定向到新域。以下是幾個url結構:
http://birmingham-printer-repairs.co.uk/brother/printer/repairs/in/abbots-langley/
http://birmingham-printer-repairs.co.uk/brother/printer/repairs/in/accrington/
http://birmingham-printer-repairs.co.uk/sharp/printer/repairs/in/york/
我需要將所有包含 (word printer/repairs/in) 的 url 重定向到新域
這是我的wordpress htaccess
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^\/printer\/repairs\/in(.*)$ http://www.newdomain.com/ [R=301,L]
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
uj5u.com熱心網友回復:
您可以使用以下內容:
請記住:這應該在您的 htaccess 的頂部或其他指令之前
RewriteEngine On
RewriteRule printer/repairs/in https://example.com [L,R]
如果兩個域(新的和舊的)都指向同一個檔案根,那么使用這個
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.com$
RewriteRule printer/repairs/in https://example.com [L,R]
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/441224.html
上一篇:阻止以數字開頭的網站頁面
