Mobile app version of vmapp.org
Login or Join
Ann8826881

: Redirecting www.foo.example.com to foo.example.com I have a Cpanel web hosting account and have created a subdomain which redirects to an IP address of a different server (Windows IIS) by creating

@Ann8826881

Posted in: #Cname #Cpanel #Dns

I have a Cpanel web hosting account and have created a subdomain which redirects to an IP address of a different server (Windows IIS) by creating an A record. I don't have control of the Windows server.

I would like that those people who type before the subdomain get redirected to the same page.

I tried creating a CNAME record pointing foo.example.com. to foo.example.com but it isn't working. It is actually stopping the A record from working.

How do I redirect foo.example.com. to foo.example.com in Cpanel?

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Ann8826881

2 Comments

Sorted by latest first Latest Oldest Best

 

@Angie530

You can follow these 2 steps in order to achieve the same.

Step 1) Delete the CNAME record that is redirecting(at the DNS Level) foo.example.com to foo.example.com.

In order to do this, You will have to log-in to the Advanced DNS Zone editor present in your cPanel and delete the following CNAME record: foo.example.com IN CNAME foo.example.com.

Step 2) You will have to add an A record pointing foo.example.com pointing to the concerned IP address.(IPv4 or IPv6).

The A record will be similar to this:
foo.example.com IN A x.x.x.x

where x.x.x.x is the IP address assigned by your web hosting provider.

10% popularity Vote Up Vote Down


 

@Shelley277

Your cPanel may have an interface to do that for you. What needs to be done, which is what such interface would do anyway, is modifying the .htaccess file in your public_html directory. It will add the following lines:

RewriteEngine ON

RewriteCond %{HTTP_HOST} ^www.foo.example.com$
RewriteRule ^/?(.*)$ foo.example.com/ [R=301,L]


Omit the RewriteEngine ON line if it is already there.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme