Introduction
This article will provide details about how to redirect domains to another page via .htaccess rules. A common issue when adding redirects in the cPanel interface is that the redirects do not take full effect because other redirects and rewrites exist in the .htaccess file. Redirects can certainly be added from inside of the cPanel interface.
See the below documentation URL for more information:
Procedure
In the SSH (via a text editor like vi, vim, or nano) or cPanel file manager, edit the .htaccess file. The below syntax will redirect the website to a specific page for all requests.
For example, the below page redirects "cptestdomain.com" and "www.cptestdomain.com" to page "www.anotherdomain.com/test-page/."
RewriteCond %{HTTP_HOST} ^cptestdomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.cptestdomain\.com$
RewriteRule ^(.*)$ "https\:\/\/www\.anotherdomain\.com\/test\-page$1" [R=301,L]
Note: If the website is WordPress or contains other Rewrites, you will need to ensure this redirect is the first redirect in the .htaccess file. It is also important to note that some regexes (Regular Expressions) are required to create a successful redirect in many instances.
The cPanel Redirects documentation page is also a good resource to build the redirects automatically in cPanel. However, if the site is WordPress, you will need to manually edit the .htaccess file to ensure the desired redirects are moved to the top of the file. The cPanel interface will only append to the existing file as this is the easiest way to write to the file and preserve the existing data.
Note: Configuring redirects can often require a systems administrator if the cPanel interface's redirects are insufficient.
Comments
0 comments
Article is closed for comments.