.htaccess redirect all pages to new domain

前端 未结 18 2433
被撕碎了的回忆
被撕碎了的回忆 2020-11-22 14:47

Which redirect rule would I use to redirect all pages under olddomain.example to be redirected to newdomain.example?

The site has a totally

18条回答
  •  春和景丽
    2020-11-22 15:30

    The below answer could potentially cause an infinite redirect loop...

    Here, this one redirects everything after the domain name on the URL to the exact same copy on the new domain URL:

    RewriteEngine on 
    RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
    
    www.example.net/somepage.html?var=foo
    

    redirects to:

    www.newdomain.com/somepage.html?var=foo
    

提交回复
热议问题