-4

Can a CNAME DNS record point from subdirectory address like my.domain.com/one to domain name like my.domain.com? So if the user access my.domain.com in the browser, the DNS will redirect to my.domain.com/one.

Thanks in advance.

Mona
  • 11
  • 1
  • 2

3 Answers3

5

Nope. DNS translates CNAMES to the IP address pointed to my their target A record.

user9517
  • 115,471
  • 20
  • 215
  • 297
  • Thanks. So in my case I have created new website under subdirectory in the web server. The old website still in used(www.example.com) and the one i created is (www.example.com/new). My plan was i wanted to remove the old want and implement the new site. Is there any idea or solution to do? Im using wordpress as the platform. Thanks. – Mona Dec 10 '15 at 08:40
  • Create a second virtual host and put your new site in that and test it. Create DNS entry for the new site e.g. newsite.example.com. Do al our testing etc and when you're done just change the DocumentRoot for example.com to point to the new site – user9517 Dec 10 '15 at 10:34
4

No, DNS service is unrelated to Web, you can't do redirections with it. They should be setup in your web server.

Anubioz
  • 3,677
  • 18
  • 23
  • Thanks. So in my case I have created new website under subdirectory in the web server. The old website still in used(www.example.com) and the one i created is (www.example.com/new). My plan was i wanted to remove the old want and implement the new site. Is there any idea or solution to do? Im using wordpress as the platform. – Mona Dec 10 '15 at 08:40
  • 1
    Move your new website to subdomain like `new.example.com`. To do it - add a CNAME dns record for new.example.com, pointing to your main domain example.com, then add [VirtualHost to your apache web-server](https://httpd.apache.org/docs/2.4/vhosts/examples.html) for the new.example.com domain with DocumentRoot pointing to your new website's directory. – Anubioz Dec 10 '15 at 08:55
1

Your problem has nothig to do with DNS.

What you need is a redirect in your web server config. You can do this several ways. If you are using apache for example:

1) Using Redirect directive - https://httpd.apache.org/docs/2.2/mod/mod_alias.html#redirect

2) Using ModRewrite - https://stackoverflow.com/questions/990392/htaccess-rewrite-to-redirect-root-url-to-subdirectory

EvilTorbalan
  • 625
  • 4
  • 10