.htaccess redirect all pages to new domain

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

    Simple just like this and this will not carry the trailing query from URL to new domain.

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteRule .* https://www.newdomain.com/? [R=301,L]
    
    0 讨论(0)
  • 2020-11-22 15:34

    Try this methode to redirect all to homepage new domain, Its works for me:

    RewriteCond %{HTTP_HOST} ^olddomain\.com$ [OR]
    RewriteCond %{HTTP_HOST} ^www\.olddomain\.com$
    RewriteRule ^(.*)$ "https\:\/\/newdomain\.com\/" [R=301,L]
    
    0 讨论(0)
  • 2020-11-22 15:35

    If you want to redirect from some location to subdomain you can use:

    Redirect 301 /Old-Location/ http://subdomain.yourdomain.com

    0 讨论(0)
  • 2020-11-22 15:39

    If you want redirect to complete new different site (domain) with no parameters or pages, use this:

    RewriteEngine On
    RewriteRule / http://new-domain.com/$1? [R=301]
    
    0 讨论(0)
  • 2020-11-22 15:41

    May be like this:

    Options +FollowSymLinks
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^OLDDOMAIN\.com$ [NC]
    RewriteRule ^(.*)$ http://NEWDOMAIN.com [R=301,L]
    
    0 讨论(0)
  • 2020-11-22 15:41
    <IfModule mod_rewrite.c>
      RewriteEngine On
      RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
      RewriteCond %{HTTP_HOST} ^www.olddomain.com$
      RewriteRule (.*)$ http://www.newdomain.com/$1 [R=301,L]
    </IfModule>
    

    This worked for me

    0 讨论(0)
提交回复
热议问题