Redirect website multiple domain to single domain using htaccess



Code: copy below code and create .htaccess file and past it.



            RewriteEngine on  
            RewriteCond %{HTTP_HOST} ^http://domainname.com [OR]
            RewriteCond %{HTTP_HOST} ^https://www.domainname.com [OR]
            RewriteCond %{HTTP_HOST} ^http://www.domainname.com [OR]
            RewriteCond %{HTTP_HOST} ^www.domainname.com
            RewriteRule ^(.*)$ https://domainname.com/$1 [R=permanent,L]

                    #   or

            RewriteEngine on  
            RewriteCond %{HTTP_HOST} ^domainname.com
            RewriteRule ^(.*)$ https://www.domainname.com/$1 [R=permanent,L]

        

Comments