DNS entry to redirect constant url to changing directory name
I have static content that is regularly updated that I'd like to maintain 100% up-time for when switching over to new content.
Ideally I'd like to provide a single url such as:
static.mydomain.com/tiles/
that actually redirects to something like
static.mydomain.com/tiles-2016-03-01/
then when I roll-out a fresh update I can quickly update the DNS record to redirect to the new files
static.mydomain.com/tiles-2016-04-28/
Is this possible with DNS alone? Perhaps there's an alternative non-DNS solution I can use?
BTW I have numerous tile sets so would prefer to host them all under static.mydomain.com.
At present I deploy my new content to
static.mydomain.com/tiles-NEW
I then rename the existing "tiles" to "tiles-OLD", followed by renaming "tiles-NEW" to "tiles". Unfortunately this process takes a while due to the huge number of files held under each directory, so renaming via FTP or the web based control panel (my only options) results in a fair amount of downtime. As the site is popular at least some users are always going to experience issues during my renaming process.
Also using a quick DNS change would allow me to quickly roll back to an older version of my files if a problem was discovered with the update.
I'm using CloudFlare for my DNS if this has any relevance to potential solutions.
Alternative Solution
As this is outside the abilities of DNS I solved it using a simple web.config file on IIS (a .htaccess can be used instead on Apache):
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="tiles">
<match url="^tiles/(.*)" />
<action type="Redirect" url="tiles-20160428/R:1" redirectType="Found" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
No.
A DNS (domain name server) record can only associate Internet numbers and domain names in different ways, such as an A (IPv4) record, AAAA (IPv6) record, and MX (mail server, where to send email to). You cannot give instructions through DNS, such as a 301 or 302 Redirect response, which is what I believe you're asking for. You are going to need to use a web server and/or a content language like Go/PHP to accomplish what you have set out to do.
Comments
Post a Comment