Sometimes we need to redirect our complete Website or Webpages to another URL or New Domain; reason can be anything as:
Then you can perform the redirection by doing some changes in .htaccess file. .htaccess code to redirect complete website all pages to new domain home page by using htaccess redirect 301:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) https://www.new-domain.com/? [R=301,L]
With the help of above code user can redirect a complete website to another URL. And you can also redirect the individual webpages to new pages by using below code :
Redirect 301 /old-page.html https://www.domain.com/new-page.html
Use below .htaccess code to redirect all website pages to a folder or a page on same server/domain
Suppose you are having a forum https://www.domain/forum/ having more than 200 pages cached. Now you want to remove forum and would like to redirect all pages of forum to https://www.domain/forum/ or https://www.domain/, then below code will work for you.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule \/.+ /corruptmdfrepair/ [L,R]