Redirecting a specific page to another domain

后端 未结 2 658
误落风尘
误落风尘 2021-01-25 02:15

I recently created a new site on a different domain. I need to redirect the index.html of the old domain to the index of the new domain.

Usually this would

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-25 02:38

    You can try mod_rewrite for more flexibility with the code like this:

    Options +FollowSymlinks -MultiViews
    RewriteEngine on
    
    # for HTTP
    RewriteCond %{HTTP_HOST} ^a\.com$ [NC]
    RewriteCond %{SERVER_PORT} =80
    RewriteRule ^(index\.html)$ http://b.com/$1 [R=301,L,NC]
    
    # for HTTPS
    RewriteCond %{HTTP_HOST} ^a\.com$ [NC]
    RewriteCond %{SERVER_PORT} =443
    RewriteRule ^(index\.html)$ https://b.com/$1 [R=301,L,NC]
    

提交回复
热议问题