.htaccess redirect all pages to new domain

前端 未结 18 2288
被撕碎了的回忆
被撕碎了的回忆 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:33

    If the new domain you are redirecting your old site to is on a diffrent host, you can simply use a Redirect

    Redirect 301 / http://newdomain.com
    

    This will redirect all requests from olddomain to the newdomain .

    Redirect directive will not work or may cause a Redirect loop if your newdomain and olddomain both are on same host, in that case you'll need to use mod-rewrite to redirect based on the requested host header.

    RewriteEngine on
    
    
    RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$
    RewriteRule ^ http://newdomain.com%{REQUEST_URI} [NE,L,R] 
    

提交回复
热议问题