How to Redirect to a Different Domain

To redirect all requests to a different domain name, create a .htaccess file in your app's web root directory:


with the following contents:

RewriteRule (.*) http://NEWDOMAIN/$1 [R=302,L]

Example: Removing www. from the Domain

The following .htaccess file will redirect requests for to the same path at the domain

RewriteCond %{HTTP_HOST}
RewriteRule (.*)$1 [R=302,L]
If you are using WordPress, be sure to place these rules above the WordPress rules.

Example: Redirect Everything

You can also unconditionally redirect all requests regardless of the requested domain name. This means that no content at all will be served from your app. Every single request will be redirected.

You should only use this if the domain you are redirecting to is not part of the same app, otherwise you will create a redirect loop and requests will fail with an internal server error.

To have an unconditional redirect, just exclude the RewriteCond directive in the examples above.

The following file will redirect all requests to

RewriteRule (.*)$1 [R=302,L]