If you are looking to redirect traffic from one domain to another, the easiest way would be to edit the .htaccess file located by default in the /var/www/html/ directory.

The .htaccess file uses mod_rewrite and should look like the following:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

 

To redirect traffic to another domain, add the following rewrite rule underneath the last line of the example config:

 

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} testsite\.net$ [NC]
RewriteRule ^(.*)$ https://testsite.cloud/ [L,R=301]
</IfModule>

 

Once added, restart apache and thats it.

Hope this helped.

Leave a Reply

Your email address will not be published. Required fields are marked *