![.htaccess 旧网站重定向到新网站,每个 url 单独重定向](https://linux22.com/image/761616/.htaccess%20%E6%97%A7%E7%BD%91%E7%AB%99%E9%87%8D%E5%AE%9A%E5%90%91%E5%88%B0%E6%96%B0%E7%BD%91%E7%AB%99%EF%BC%8C%E6%AF%8F%E4%B8%AA%20url%20%E5%8D%95%E7%8B%AC%E9%87%8D%E5%AE%9A%E5%90%91.png)
我有一个网站已迁移到另一个 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>