inteldigital

Well-Known Member
Apr 5, 2018
88
15
8
England
cPanel Access Level
Root Administrator
Twitter
Hi,

Is there a way I can addon a domain name, and redirect it using masking. I'm trying to achieve the following:

exampledomain.com has a website on it and isn't hosted locally. I add into my cPanel account, exampledomain2.com and when I click to exampledomain2.com I want to see exampledomain.com website, but the URL bar to say exampledomain2.com.

How do I achieve this. I know there was a way previously, but can't see it anymore.
 

GOT

Get Proactive!
PartnerNOC
Apr 8, 2003
1,770
324
363
Chesapeake, VA
cPanel Access Level
DataCenter Provider
You can add it as an domain alias and it will behave the way you want, assuming you do not use any rewrites in your code or htaccess that push it back to the primary domain.
 

Vinayak

Well-Known Member
Jun 27, 2003
288
6
168
Bharat
cPanel Access Level
Root Administrator
Use .htaccess file to do that, with following code

Code:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^exampledomain\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.exampledomain\.com$
RewriteRule ^/?(.*) http://www.exampledomain2.com/$1 [R=301,L]
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,884
2,254
463

ADG

Registered
Apr 29, 2021
2
1
1
sydney
cPanel Access Level
Root Administrator
how would I do this to point to a subdomain?
It works in essence but didn't load the HTML page sitting in the subdomain



RewriteEngine On
RewriteCond %{HTTP_HOST} ^sub.mydomain\.com.au$ [OR]
RewriteCond %{HTTP_HOST} ^www\.sub.mydomain\.com.au$
RewriteRule ^/?(.*) https://www.othersite.com/$1 [R=301,L]
 
Last edited by a moderator: