I have dealt with using rewrites and rules to forward things in Apache or IIS. I am wondering if I have our current domain name test123.example forwarded to test678.example what will happen if someone is going to test123.example/home/products/industrial/product123?

Will it keep the underlying URL behind the domain name while being forwarded? Is there anything that I should think about this before deciding? And this is SSL site using certificate.

  • Just to clarify, you are just talking about DNS?
    – MrWhite
    Jan 25, 2017 at 22:46
  • 2
    ...forward a domain permanently via DNS... Impossible. Cannot be done. DNS does not forward. It only assigns a domain name to an IP address and optionally assign a few other records for look-up. Nothing more.
    – closetnoc
    Jan 25, 2017 at 23:03
  • @closetnoc - should have said redirect not forward. My bad on the terminology. Even redirect is a bad term, should be that old resolves to new but these are all the same concept.
    – blankip
    Jan 26, 2017 at 0:29
  • 2
    It still does not forward. It does allow you to assign several domain names to an IP address or another domain name using a CNAME (alias) record, if that is what you mean. If it is, then example.com/myspiffywebpage/ should still work if aliased to otherexample.com.
    – closetnoc
    Jan 26, 2017 at 0:41

3 Answers 3


This is a really old question that has resurfaced, but none of the answers seem to answer the OP's question. The OP question is about DNS (see the tags), not about redirecting. So,let me try to explain/answer the OP's question for the benefit of newer users.

When a browser needs to communicate with a webserver, it passes the host/domain name to the OSI stack to resolve the name only. It doesn't pass any information besides the host.domainname.tld. I.e., it doesn't pass anything about the home/products/industrial/product123 portion of the request.

The host information gets passed to a name resolution service that uses a combination of hosts files, cache, DNS and possibly other vendor specific services to resolve the name to an IP address.

Once resolved, the IP address of the host.domainname.tld is passed back to the client machine. The client machine then sends the URL along to a TCP service that makes a connection to the destination IP address without regard to home/products/industrial/product123. The destination server passes the Fully Qualified Domain Name (host.domainname.tld) request up the OSI stack to the web service for processing.

The web service, then matches the host.domainname.tld to the hosted website.

Finally, the web service, connects with the file service to match the home/products/industrial/product123 portion of the user's request to the server's content/page and returns the result back to the client browser.

Long explanation, but here's the point. The only two pieces of software involved in locating the file in the URL (not the domain) are the client browser and the web server's web software.

As a result, changing the DNS records only changes the IP address that is resolved for the host.domainname.tld and has no effect on the file location.

That being said, if the file/web structure test123.example.com is different from test678.example.com, simply changing the DNS records will only send the user to the correct server, but not necessarily the correct file/page.

I'm guessing some of the protocols/OSI stacks are different between servers and have changed over the years, so feel free to add corrections as needed.


With DNS, it does not matter if it is an A record (resolve to an IP directly) or a CNAME record (resolves to another domain), the request from the browser will still reference the original hostname test123.example.

If done with https, the "destination" server should serve a valid certificate for the "original" server name or the client will get an unpleasant error ("site is not safe", "hackers may be intercepting your communications" and so on).

If only serving through http, it will depend on the config of the destination server to present the intended page or respond with something else (if the destination server does not allow the original servername), like a 400 error, a redirection to some "default" page, etc. NOTE: this case could also apply to the https case after the potential SSL error with the certificate.

Change your /etc/hosts or %WINDIR%\system32\drivers\etc\hosts to simulate the change beforehand and check what problems you will encounter.


It depends on your configuration.

Example: Redirect to fixed url

<VirtualHost *:80>
    ServerName test123.example
    RewriteEngine On
    RewriteRule ^.*$ https://test678.example/? [R=301,L]

This redirects every request to the URL http://test123.example/ and ignores the previous URL.

Don't forget the ? at the end of the hostname or the parameter part (everything that follows the ?) will be still appended.

Example: Redirect with uri

<VirtualHost *:80>
    ServerName test123.example
    RewriteEngine On
    RewriteRule ^.*$ https://test678.example%{REQUEST_URI} [R=301,L]

This sends a Location header with the old request URL intact.

Things to consider

For better google results (SEO) and UX you should always reduce 404 errors.

If you are migrating to a new server name and the entire file hierarchy remains unchanged, I would advise to use the seconds example and keep the URL as is.

If the new server doesn't contain all the old pages and would result into 404 errors you should go with the first option.

  • Your first example doesn't "redirect to a fixed url", in fact, it does the same as the second example and redirects test123.com/<anything> to test678.com/<anything>. "This sends a Location header with the old request uri" - The same as the first example, it sends a Location header with the new request URI (not the "old" one?).
    – MrWhite
    Jan 25, 2017 at 22:45
  • @w3dk omg I'm so sorry - I just looked at the documentation which is not that great apparently Jan 25, 2017 at 22:51
  • 1
    I am sorry. This does not answer the OP's question. He is asking about DNS. Cheers!!
    – closetnoc
    Jan 25, 2017 at 23:04
  • @closetnoc well I weren't quite sure with his grammar. Did he already changed something in Apache or IIS? Does he just want to make a CNAME? Sorry I'm new on this board and couldn't ask him in a comment. :( Jan 25, 2017 at 23:10
  • I am not kicking your butt. Honest! We all misread things from time to time and sometimes questions are just not clear. I only mention it so that you can edit your answer. I make these comments to help new users just like people did for me when I was new. Cheers!!
    – closetnoc
    Jan 25, 2017 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.