URL Support

General info
Starting release v. 0.071 PowerDNS for WHMCs supports the URL-record type.

Please follow these guidelines to succesfully setup support for the URL-record type.

With the URL-record type you have an enhanced version of the CNAME-record type. With CNAME you can only redirect to another URL. With the URL-type record you can redirect to specific pages.

EXAMPLES
With CNAME
contentpeople.eu IN CNAME contentpeople.nl
With URL
contentpeople.eu IN URL contentpeople.nl/mypage

In this example the URL-record type will redirect the complete domain to a page of our website in the Dutch language.

How does it work?
When you use the URL-type record PowerDNS will redirect the request to a website (defined in pdns.conf). The website - a simple script - will look up the desired location and do the actual forwarding.

Enabling URL-record type support is easy. It can be done in less then five minuts!

1. Edit pdns.conf
2. Enable fancy records: fancyrecords=yes
3. Enable the urlredirector: urlredirector=1.1.1.1 (your ip-address)
4. Save and restart PowerDNS.
5. Please follow step 1 to 4 on all your DNS-servers.

6. Go to the config file of your webserver.
7. Add a new host. Please use a dedicated IP-address for this, so Apache will not get confused.

<VirtualHost _default_:80>
ServerAdmin hostmaster@localhost
DocumentRoot /var/www/html/urlredirect
ErrorLog logs/urlredirect-error_log
CustomLog logs/urlredirect-access_log common
</VirtualHost>

8. Restart Apache
9. Add an index.php script in the root of the virtualhost

<?php
// Get the server name our user requested
$servername = $_SERVER["HTTP_HOST"];
// replace this with credentials to your powerdns database
@mysql_connect('db-host','username','password');
// replace this with the right database name
@mysql_select_db('powerdns');
$result = @mysql_query("SELECT content FROM records WHERE name = '$servername' AND type = 'URL' LIMIT 1");
// Query for our redirection
if (mysql_num_rows($result) == 1) {
// we got a result, redirect to that
$row = @mysql_fetch_object($result);
header("Location: $row->content");
} else {
// we didn't get any result for unknown reason, redirect to failsafe place
header("Location:
http://www.google.com");
}
?>

10. Finished


Read on!
- The PowerDNS manual.
- This text has been based on a blog at Weberns Hideout.