deverne.net

Friday, September 26, 2008

Wildcard DNS with Hostgator

I've been trying for two days to figure out how to set up fake subdomains for a website.

After googling, I finally found out.

I asked Hostgator to set up Wildcard DNS. While waiting for their response (only an hour or so), I found this post ...
http://forums.hostgator.com/wildcard-subdomains-t36638.html.

When following the directions to add a subdomain called * and pointing to the root of your subdomain, I noticed that Hostgator had done exactly that with my main domain for the account.

Since my add-on domain wildcard DNS didn't work with just the main domain configured, I figured I try the same trick with the add-on domain itself. It works like a charm.

So I grab the fake subdomain portion of the URL and pass it to the index.php page in the .htaccess file like this ...

Options +FollowSymLinks
RewriteEngine on
RewriteBase /

RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com?$
RewriteRule ^$ http://www.domain.com/index.php?name=%1 [L]

Then I can process at the page level. Or I can configure an internal redirect within the .htaccess file.

Once I clean it up, I'll be posting soon about how to grab the file names in a directory and sorting and displaying them. So all you have to do is add a file to the directory and it will automatically be displayed, no database required.

Bye for now.

Labels: , ,

Thursday, September 04, 2008

Just Had To Post This ... (Sarah Palin)