Skip to content

How to redirect all urls and traffic from one domain to another using .htaccess.

Jul 30, 2018 | Server Administration

Global Redirect of all urls from one domain to another in .htaccess

Often we find ourselves needing to redirect all traffic from one domain, no matter what page is hit, to a completely different domain.

E.g.

www.olddomain.com/whatever.html

www.olddomain.com/somethingelse.php

www.olddomain.com/anotherthing.htm

Would all need to redirect to:

www.some-other-domain.com

To do this, you can add the following to your .htaccess file:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^olddomain.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.com$
RewriteRule (.*)$ http://www.some-other-domain.com/$1 [R=301,L]
</IfModule>

If processed correctly, you should now have a global direct from one domain to the other now in place.

Place this as close to the top of your directives in your .htaccess file. If you find yourself having trouble, try to remove everything else in your .htaccess file and see if the redirects process for you, then you can troubleshoot where your conflict is in the .htaccess file.

As always, if you need a paid consult, just use the form below and we’ll see if we can help.

Contact Us Today!

"*" indicates required fields

I would like to be contacted by:*
This field is for validation purposes and should be left unchanged.

Join Our Newsletter List!

* indicates required