我有一个网站已迁移到另一个 URL。因此,我想将我之前的所有 URL 迁移到具有不同段的新 URL。例如
主要重定向
旧网站是:https://myoldsite.abc
新网站是:https://mynewsite.xyz我还想将所有其他页面重定向到新 URL
旧网站是:https://myoldsite.abc/myfolder
新网站是:https://mynewsite.xyz/new_url_1旧网站是:https://myoldsite.abc/myfolder/old_url
新网站是:https://mynewsite.xyz/new_url_2旧网站是:https://myoldsite.abc/myfolder/abc_url
新网站是:https://mynewsite.xyz/new_url_3简单 URL
旧网站是:https://myoldsite.abc/testing_url
新网站是:https://mynewsite.xyz/New_testing_url_1
我的代码看起来像这样
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^myoldsite.abc [NC,OR]
RewriteCond %{HTTP_HOST} ^www.myoldsite.abc [NC]
RewriteRule ^/myfolder/url_1/?$ https://mynewsite.xyz/new_url_1 [R=301,L]
RewriteRule ^/myfolder/url_2/?$ https://mynewsite.xyz/new_url_2 [R=301,L]
RewriteRule ^/myfolder/url_3/?$ https://mynewsite.xyz/new_url_3 [R=301,L]
RewriteRule ^/myfolder/url_4/?$ https://mynewsite.xyz/new_url_4 [R=301,L]
RewriteRule ^/myfolder?$ https://mynewsite.xyz/new_url_4 [R=301,L,NC]
RewriteRule ^(.*)$ https://mynewsite.xyz [R=301,L]
</IfModule>