我有一個網站已遷移到另一個 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>