Custom index.html for subdomains

ditto

Verified User
Joined
Apr 27, 2009
Messages
2,348
I am trying to create a custom index.html for new subdomains in DirectAdmin. I have used this guide http://help.directadmin.com/item.php?id=187

The custom index.html for subdomains is created without problems, however I am not able to use code in the index.html template like this:

Code:
|DOMAIN|
|DATECREATED|

That code is only displayed in plain text when the index.html for a subdomain is created. However I am able to use that code in the template for normal domains, only for subdomains it does not work.

Is it possible to use |DOMAIN| and |DATECREATED| in the template for index.html for subdomains?
 
It might work if you put it in the
/usr/local/directadmin/scripts/custom/subdomain_create_post.sh file like:

echo "|DOMAIN|" >> $INDEX

instead of just copying the file from another area with the variables already in there.

html has no idea what those variables are.
 
...html has no idea what those variables are.

You can use |DOMAIN| and |DATECREATED| in index.html file for domains at /home/admin/domains/default/index.html - and for subdomains I did the step in the link in my first post, and was hoping I could use them in index.html created for subdomains at /home/admin/domains/subdomain/index.html - however it does not seem to work.

I am still trying to search for solutions, but have not found any yet. Is there not anybody else here that have done this?
 
Why don't you follow example suggested by user scsi? You can do with /usr/local/directadmin/scripts/custom/subdomain_create_post.sh whatever you might want.
 
Why don't you follow example suggested by user scsi? You can do with /usr/local/directadmin/scripts/custom/subdomain_create_post.sh whatever you might want.

I did try it, but did not get it to work. Here is the content of /usr/local/directadmin/scripts/custom/subdomain_create_post.sh

Code:
#!/bin/sh
INDEX=/home/$username/domains/$domain/public_html/$subdomain/index.html
rm -f $INDEX
cp /home/admin/domains/subdomain/index.html $INDEX
echo "|DOMAIN|" >> $INDEX
chown $username:$username $INDEX
exit 0;

All it does is that it in plain text add "|DOMAIN|" at the bottom of index.html.
 
Sure, it won't work as expected. You should use instead real variables and sed with the script:

something like:

Code:
...skipped...
sed -e "s/|DOMAIN|/$domain/" /home/admin/domains/subdomain/index.html | sed -e "s/|SUB|/$subdomain/" > $INDEX
...skipped...

If you need more content

p.s. I did not suggest using the whole example. Just the script.
 
My guess is that index.html for the main domain the variables are changed before copying to the users home directory. You might need to ask directadmin support why it doesnt work as you expect with subdomains. Maybe there is a bug they dont know about.
 
Hello,

As zEitEr mentioned, it's not a template, it's just a post script. |TOKENS| don't work there, but variables do.

If you have your own template html you want to use, you can use perl to swap them, as zEitEr mentioned (sed would also work).
Code:
#!/bin/sh
INDEX=/home/$username/domains/$domain/public_html/$subdomain/index.html
rm -f $INDEX
cp /home/admin/domains/subdomain/index.html $INDEX
perl -pi -e  "s/|DOMAIN|/$domain/" $INDEX
perl -pi -e "s/|SUB|/$subdomain/" $INDEX
perl -pi -e "s/|DATECREATED|/`date`/" $INDEX
chown $username:$username $INDEX
exit 0;
I didn't test this code for syntax errors, but it's essentially what you'd need.

John
 
Back
Top