: Basic DNS and URL Redirect for just a web server I am unable to find the proper setup of DNS records with URL Redirect service for a basic web server where: Any URL with www.Example.com
I am unable to find the proper setup of DNS records with URL Redirect service for a basic web server where:
Any URL with Example.com should go to server with IPv4 number 1.2.3.4
Any URL for example.com or Example.com should be replaced with a URL of Example.com.
I do not really understand forwarding versus redirecting. What I want is to transform any "example.com" request to a "www.Example.com" request (always using the 'www', and not respecting the naked 'example.com').
No other services rendered on this server except the web server (and ping etc.). So no concern about email servers, FTP servers, etc.
Sites will have TLS security certificates engaged.
Should it be:
Type: A Record
Host: @
Value: 1.2.3.4
TTL: Automatic
Type: CNAME Record
Host: www
Value: example.com
TTL: Automatic
Type: URL Redirect Record
Host: @
Value: www.Example.com/ Unmasked
More posts by @Tiffany637
2 Comments
Sorted by latest first Latest Oldest Best
There is no such thing as a "URL redirect record" in DNS. To redirect a domain, you need enter the IP address of a web server that is configured to issue an HTTP redirect.
I would take the approach of putting the same IP address for both your apex record and your www record:
.example.com A 1.2.3.4 example.com A 1.2.3.4
Then on your webserver you can set up a virtual host that does the redirect and one that serves content:
<VirtualHost *:80>
ServerName example.com redirect permanent / example.com/ </VirtualHost>
<VirtualHost *:80>
ServerName example.com
DocumentRoot "/www/example.com"
....
</VirtualHost>
Many web hosts don't allow you to edit your own virtual host files. Those hosts typically have the bare domain and the www domain set up to be handled in the same virtual host. In that case, you can just use some .htaccess rules to do the redirects
RewriteEngine On
RewriteCond %{HTTP_HOST} !=example.com [NC]
RewriteRule ^(.*) example.com/ [NS,L,R=permanent]
You want an A record on host www pointing at your IP address. That will take care of example.com.
For example.com -> example.com you need a redirect. As noted in the comments, DNS on its own cannot redirect, but many DNS providers offer some sort of redirection service. The capabilities of these will vary a bit between providers. You may be able to setup a redirect on host @ to example.com, which would do what you want. However, your provider may not allow you to have this in addition to the example.com A record (i.e. you might only be able to redirect the whole domain). In this case you would need to set an A record and handle the redirect yourself (how to do this will depend on what web server you are using - see this question for an example of how to do it with Apache).
Also note that domains are case insensitive. There is no difference between example.com and Example.com, so you can't redirect from one to the other. Browsers will usually display them as lowercase.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.