How can i redirect my site to another url using htaccess?

You can redirect your complete site (when someone type your domain) to another URL, placing the following lines in your .htaccess file in your public_html directory:

 

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.yourdomain.com$
rewriterule ^(.*)$ http://www.newurl.com [R=301,L]

 

This will not follow the path, which means anything you type after the domain will always redirect to the new url. For example, someone typing http://yourdomain.com/myforum will redirect to http://www.newurl.com

 

If you wish it follow the path, for example if someone type http://yourdomain.com/myblog redirect to http://www.newurl.com/myblog, please check the Domain Redirection section in you cPanel, you can easily set it up that way from there.



  • 5 Users Found This Useful
Was this answer helpful?
Related Articles
Copyright © 2020 PlusPlusHosting.Net. All Rights Reserved.
2Checkout.com is an authorized reseller of goods and services provided by PlusPlusHosting.Net.