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

public/.htaccess

with the following contents:

RewriteCond %{HTTP_HOST} =OLDDOMAIN
RewriteRule (.*) http://NEWDOMAIN/$1 [R=302,L]

Example: Removing www. from the Domain

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

RewriteCond %{HTTP_HOST} =www.example.com
RewriteRule (.*) http://example.com/$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 example.com.

RewriteRule (.*) http://example.com/$1 [R=302,L]
Alert: For Control Panel Help & Tutorials, click here: Panel Tutorials
Was this answer helpful? 0 Users Found This Useful (0 Votes)

Powered by WHMCompleteSolution