Here are the steps to redirect the domain without changing the URL:
First, you need to login into cPanel and open the file manager.
Click on public_html and then .htaccess
Right-click on .htaccess, and choose the edit option.
By clicking on the edit option, one box will appear in which you have to click on the "Edit" button displayed in the bottom right corner.
For instance, your visitors are visiting "xyz.com," but you want to redirect them to "xyz2.com" without making any changes to the URL. Then, just write the below-mentioned Line using the .htaccess file.
RewriteEngineOn
RewriteCond%{HTTP_HOST} ^xyz.com RewriteRule ^(.*) http://xyz2.com/$1 [P]
The first Line acknowledges the Apache to begin the rewrite module.
The redirection from the source domain to the target domain is indicated on the Second Line.
You can also write these lines in your .htacccess
RewriteCond%{HTTP_HOST} ^xyz.com RewriteRule ^(.*)
http://xyz2.com/redirectedpage [P]
Besides, you can also redirect the IP address to another website. You need to add the following lines to the .htaccess file.
RewriteCond%{HTTP_HOST} ^192.168.45.11 RewriteRule (.*) http://xyz2.com/$1 [R=301,L]
Now that this redirect is complete, the server will show you the result.
The L indicates the Last rule in the run.
The R=301 indicates that the web server permanently sends a 301 to the requesting browser or search engine.