jlandes
Verified User
As many of you may already know, whenever subdomains are added within DirectAdmin, no default index file is created in the subdomains root directory. This may have a tendency to confuse some users, as they think their subdomains are not working correctly because when they try to view them they get an error until an index file is placed in the directory.
I have been able to resolve the issue on my system by doing the following:
First, create the file subdomain_placeholder.html in the directory /usr/local/directadmin/data/templates/custom/. Then, place the following code in the file.
Now chmod the file to 644 and chown to diradmin:diradmin.
Next, create the file subdomain_create_post.sh in the directory /usr/local/directadmin/scripts/custom/ if it does not already exist and add the following code to it. If it does already exist, just add the code to the file that is already there. Follow the normal DirectAdmin recommended method for creating this file, chowning it, and chmoding it.
I'd be interested in hearing your thoughts about what I've done here. Are there any recommendations?
I have contacted DirectAdmin and have asked them if it would be possible to have an index file automatically created when new subdomains are added, much like what is done when a regular domain is added.
I have been able to resolve the issue on my system by doing the following:
First, create the file subdomain_placeholder.html in the directory /usr/local/directadmin/data/templates/custom/. Then, place the following code in the file.
Code:
<html>
<head>
<title>
|SUBDOMAIN|
</title>
<style>
* { font-family: verdana; font-size: 10pt; COLOR: gray; }
b { font-weight: bold; }
table { border: 1px solid gray;}
td { text-align: center; padding: 25;}
</style>
</head>
<body>
<center>
<br><br><br><br>
<table>
<tr><td>This is a placeholder for the subdomain <b>|SUBDOMAIN|</b></td></tr>
</table>
<br><br>
</center>
</body>
</html>
Now chmod the file to 644 and chown to diradmin:diradmin.
Next, create the file subdomain_create_post.sh in the directory /usr/local/directadmin/scripts/custom/ if it does not already exist and add the following code to it. If it does already exist, just add the code to the file that is already there. Follow the normal DirectAdmin recommended method for creating this file, chowning it, and chmoding it.
Code:
#!/bin/sh
#Create default index page for the subdomain
TEMPLATE_DIR=/usr/local/directadmin/data/templates/custom
TEMPLATE_FILE=$TEMPLATE_DIR/subdomain_placeholder.html
DEST_DIR=/home/$username/domains/$domain/public_html/$subdomain
DEST_FILE=$DEST_DIR/index.html
cp $TEMPLATE_FILE $DEST_FILE
chmod 644 $DEST_FILE
chown $username:$username $DEST_FILE
STR="perl -pi -e 's/\|SUBDOMAIN\|/$subdomain.$domain/' $DEST_FILE"
eval $STR;
exit 0;
I'd be interested in hearing your thoughts about what I've done here. Are there any recommendations?
I have contacted DirectAdmin and have asked them if it would be possible to have an index file automatically created when new subdomains are added, much like what is done when a regular domain is added.