Cheap Domains, $1 .COM Websites! - Free .COM (or $1.99) on Many Products!
 
Only Minimal Purchase Req'd on Many Free/$1.99 .COM Offers.    And Our Sale Domains are Often Under $2 or $3/year with No Further Purchase Req'd.
 
Plus, almost ALWAYS 15% OFF Everything Not Already Discounted.    15% OFF Most Renewals too!      New: Business-Growth Website-Builders and Hosting!
 

 *ICANN fee adds 18ยข many domains; tas applies some areas.  Our $1 Website Builder with Free .COM is based on 12 months at $1/mo.   Multipile or "Stacked" discounts in same purchase often disallowed (may require separate transactions).  Click for details.

 
Cheap Domains Cheap Domain Names

  
Use Promo HDX for at least
Cheap .com
that's not already On Sale!*
 

Cheap Domains     $1 Websites     Free USA-based Sales/Support:  (800) 655-5512
 

.COM $7.64 (Promo: HDX) |  .NET $10.19  |  .SITE $2.99  |  .ORG $11.99  |  .XYZ $0.99  |  .UK $7.64  |  .EU $6.79

Cheap Domains include FREE:  100 Email Addresses & Account, Full DNS Control, Domain Forwarding, Masking, Registrant-Change/Transfer, Monitoring/Alerts, Locking, Expiration Protection, More!

Cheap Domains - Find Yours Now:    
 
Most prices shown
use Promo Code: HDX.  This search function, and most product pages, display higher prices at first, but don't worry,  Discounts appear in Shopping Cart when Promo Code Entered    details

Free .COM Domains!   often with: cPanel Hosting,

  Plesk Hosting, Managed WordPress Hosting, Business Hosting

$2 Website & Business Website Builder

   

$1.99 .COM Domains  often offered on: Spam-Free Email,

Online Group Calendar, Online Storage, SSL Certificates, more!

 
Terms & Conditions Here.  Add a .COM to Cart to verify price if product description not specific..

 

 
 

 Cheap Cloud Hosting      Cheap WordPress Hosting      Sell Online! Easy Shopping-Cart Website - $8
Cheap Dedicated Servers       Cheap Virtual Private Servers      
Cheap cPanel Hosting 

 
$1 Domains | $1 .COM 
 
  

Frequently Asked Questions

Too many files in one folder? Try a dirtree.

Print this Article
Last Updated: March 21, 2017 8:36 AM

Too many files in a single folder/directory - 1,000 or more - causes severe performance problems on most file systems. If the files are already linked to in your HTML, simply moving them can be a hassle. Here's a solution that moves your files and uses mod_rewrite to let you leave the old links in place.

Let's say you have a dir called "files1" that has 1,000 files in it and you decide you want to move these into a dirtree (that's my name for a deep directory tree). You can do this with a consistent algorithm based on the filename so that you can systematically figure out which dir any file is in.

First, you need to move the files in "files1" to the deep directory tree, "dirtree." For this example to work, you need files in a dir called "files1" and you need an empty directory called "dirtree" to exist. This step takes an md5 hash of each filename and use the first 2 characters for the first dir and the second 2 characters for the second dir. In other words, if you have a file called 6.txt in the "files1" dir, the script will first make a "dirtree/99/af" dir, then move the 6.txt file to it.

move_files_to_dir_tree.php
<?php

# BEGIN Config
$singledir = "files1";
$dirtree = "dirtree";
# END Config

if ( !is_dir($singledir) || !is_dir($dirtree) )
	die("ERROR: $singledir and $dirtree must exist as directories already\n");

$handle = opendir($singledir);
$files = array();
while ($file = readdir($handle))
	$files[] = $file;
closedir($handle);

foreach ($files as $file)
{
	if ( ! is_file("$singledir/$file") )
		continue;
	$md5 = md5($file);
	$dir1 = substr($md5, 0, 2);
	$dir2 = substr($md5, 2, 2);
        if ( !is_dir($dirtree."/$dir1") )
		mkdir($dirtree."/$dir1");
        if ( !is_dir($dirtree."/$dir1/$dir2") )
		mkdir($dirtree."/$dir1/$dir2");
	rename("$singledir/$file", "$dirtree/$dir1/$dir2/$file");
	print "Moved $singledir/$file to $dirtree/$dir1/$dir2/$file\n";
}

Now, your thousands of files are spread out across up to 65K directories inside "dirtree". Now you can store hundreds of thousands of files and only have a few files in each folder. Pretty cool, eh?

But, what if you originally had all your files in "files1" and had tons of HTML with links to these files, maybe even more in forums and blogs? It would be a tremendous task to find and fix all of these. Fortunately, you don't have to. You can use mod_rewrite to do a redirect to your new files.

To do this, you need an .htaccess file in your original "files1" directory. You're going to detect any request for the /files1/filename pattern and have dirtree.php process it.

.htaccess
RewriteEngine On
RewriteBase /
RewriteRule ^files1/([^/]+)$ /dirtree.php?file=$1 [L]

Finally, you need a dirtree.php file containing the following code in the "files1" directory. This sends a redirect header back to the browser to tell it where the files are now.

dirtree.php
<?php
# BEGIN Config
$dirtree = "/dirtree";
# END Config

$file = $_GET['file'];
$md5 = md5($file);
$dir1 = substr($md5, 0, 2);
$dir2 = substr($md5, 2, 2);

header("Location: $dirtree/$dir1/$dir2/$file");
exit;
1 Dollar Website includes FREE .COM DOMAIN name
 


Toll Free Technical Support from a USA Call Center, 24 hours a day, 365 days a year:    (800) 655-5512
 
Call us with any sales or support question.     Place Orders by Phone.    Our USA-based Help Desk speaks your language.
 

Call Centers located in the Greater Phoenix metro area and Central Iowa, USA.     Technical Support also available in Spanish   New to Us?  Get a free account in 60 seconds.


 

 

 $1 Domains   |   $1 Websites   |   Product Catalog   |   Sale Price FAQ   |   Help Pages   |   Free Phone Support   |   Free WHOIS Lookup   |   My Cart   |   My Account Login

 
ICANN fee of 18 cents [$0.18] may apply on some domain names.    Notice for .eu and some other registering inbound
domain transfers: WHOIS may show domain held under registry
Weiled Weast Domains and/or HostingDude.com.   Legal Agreements.

(https://cheap.hostingdude.com)
 

 


 

Copyright ? 2003 - 2019  HostingDude, Inc.  All Rights Reserved.  No reprint or re-use without written authorization.