How to browse domain,com and get sub,domain,com also with masking

Discussion in 'HOWTO-Related Questions' started by adamjedgar, Nov 15, 2019.

  1. adamjedgar

    adamjedgar Member

    Hi guys,
    What's the best way to achieve browsing domain.com however get sub.domain.com but display in browser as domain.com (masking?)

    I have an old website that is to be redeveloped. Currently website is domain.com.
    I have made a copy of it on a new server on joomla.domain.com.

    What I want to do is move the DNS so that when browsers type domain.com they are directed to joomla.domain.com for all pages on the website, however i want their web browsers to display domain.com.

    Is the way to do this add a came record as follows...

    1. domain.com CNAME joomla.domain.com (can I even do it this way?) And 2. then on joomla
    Domain.com add htaccess url mask to display domain.com in web browsers?

    Or, do I
    1. change A record for domain.com to point at new server (Domain.com), then
    2.add htaccess redirect in that vhost to joomla.domain.com with
    3. a url mask so browsers display domain.com?

    Is this a url forward or a url redirect when domain.com and joomla.domain.com is the same primary domain?

    Also, can url mask be done in DNS?
     
  2. Steini86

    Steini86 Active Member

    There are two different things:
    DNS tells the users browser which server to ask for a site. Then the server has to decide, which pages it delivers to the user. So what you want is that no matter the user asks for domain or sub.domain gets the same page. This has to be done in the webserver.

    If you really want to "mask" the domain, you need a proxy. I think you want to have a look at rewrite.
    Apache2: https://httpd.apache.org/docs/current/mod/mod_rewrite.html
    Nginx: https://www.nginx.com/blog/creating-nginx-rewrite-rules/
     
  3. adamjedgar

    adamjedgar Member

    Ok so that means its the following...
    In dns
    Domain.com CNAME joomla.domain.com

    Then the htaccess rewrite so joomla.domain.com displays all pages as domain.com.

    How does joomla config file affect the htaccess rewrite...for example I think currently it has website url as joomla.domain.com...will this prevent the rewrite from working? If so, what should I change it to?
     

Share This Page