我试图通过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/
我需要包含的所有url (word打印机/维修/in)都应该重定向到新域。
这是我对wordpress的访问
# 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
发布于 2022-03-11 05:33:22
您可以使用以下内容:
记住:这应该位于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://stackoverflow.com/questions/71433011
复制相似问题