I want to change the homepage of my domain at a specific time. How?
April 3, 2014 8:13 PM Subscribe
Pretty much what it says on the tin. I currently have index.html as the top level page on my domain. On a specific day at a specific time, I want to have that page change to e.g. index2.html more or less permanently.
I would like this to be a surprise and specifically timed, so it needs to be a) server side, and ideally b) invisible even to someone poking around.
GoDaddy is my host, I have complete backend access to everything, and know next to nothing about php or js, so please explain like I'm 5.
Response by poster: cron is indeed an option. I don't think there's any caching issues.
posted by feckless fecal fear mongering at 8:34 PM on April 3, 2014
posted by feckless fecal fear mongering at 8:34 PM on April 3, 2014
This is what cron is for. Assuming you have access to a command line and know how to use vi to edit a file, do:
...to start editing your cron jobs. Add a line to do the swap, I'd do something like (all one line, adjust times and paths to your situation):
If you don't know vi, you might be able to get access to a simpler editor like nano (try it before issuing this command to change the editor that
posted by axiom at 9:16 PM on April 3, 2014
# crontab -e
...to start editing your cron jobs. Add a line to do the swap, I'd do something like (all one line, adjust times and paths to your situation):
59 23 4 10 * cp /path/to/index.html /path/to/backup/of/old/index.html && cp /path/to/index2/html /path/to/index.html
If you don't know vi, you might be able to get access to a simpler editor like nano (try it before issuing this command to change the editor that
crontab
will use, which you would do before the crontab
command above):# export EDITOR=nano
posted by axiom at 9:16 PM on April 3, 2014
Response by poster: whoooooooosh way over my head there, GoDaddy gives me the option of scheduling cron jobs.
Do I just put what zengargoyle said in a .txt file and point godaddy there?
posted by feckless fecal fear mongering at 9:23 PM on April 3, 2014
Do I just put what zengargoyle said in a .txt file and point godaddy there?
posted by feckless fecal fear mongering at 9:23 PM on April 3, 2014
Me, I'd do this: add a new file at the root of your site called
Now, *if* in the unlikely event you have links that specifically call http://example.com/index.html rather than just http://example.com/ that would need some extra work probably an .htaccess file with this in it:
posted by artlung at 9:24 PM on April 3, 2014 [1 favorite]
index.php
. In it, put this:
<?php // current date $current_date = strtotime("now"); // April 15, 2015 at 1am. // This is server timezone dependent $target_date = strtotime("2014-04-15 01:00:00"); if ($current_date < $target_date) { include("index_old.html"); } else { include("index_new.html"); }Rename your existing
index.html
to index_old.html
and then add your new file as index_new.html
Now, *if* in the unlikely event you have links that specifically call http://example.com/index.html rather than just http://example.com/ that would need some extra work probably an .htaccess file with this in it:
RedirectMatch ^/index.html$ /But that's off the cuff have not tested that. Holler if you have any questions about this approach.
posted by artlung at 9:24 PM on April 3, 2014 [1 favorite]
Also, double check what the time is set to on the server in case it's in an unexpected time zone (or anything else is weird), so the page doesn't change hours before or after you intended!
posted by Blue Jello Elf at 9:56 PM on April 3, 2014
posted by Blue Jello Elf at 9:56 PM on April 3, 2014
Response by poster: is it possible to keep index_new from prying, nosy eyes?
posted by feckless fecal fear mongering at 10:12 PM on April 3, 2014
posted by feckless fecal fear mongering at 10:12 PM on April 3, 2014
With the cron technique you could hide it entirely but putting it a level above the web root.
With my technique this in your .htaccess file would do it:
posted by artlung at 10:30 PM on April 3, 2014
With my technique this in your .htaccess file would do it:
RedirectMatch ^/index_new.html$ /
posted by artlung at 10:30 PM on April 3, 2014
Response by poster: So if I put that line in .htaccess, it'll find index_new wherever I hide it?
(I know I know, AskMe is not for back-and-forth but this is the only way I can understand)
posted by feckless fecal fear mongering at 10:36 PM on April 3, 2014
(I know I know, AskMe is not for back-and-forth but this is the only way I can understand)
posted by feckless fecal fear mongering at 10:36 PM on April 3, 2014
This is actually not what cron is for - cron is for repeating events. To schedule a one-time event, just type
at 2 PM tues
or whenever, then hit return and type
mv index2.html index.html
and return and Ctrl-D. Type man at for more information on the "at" command.
posted by nicwolff at 10:37 PM on April 3, 2014 [4 favorites]
at 2 PM tues
or whenever, then hit return and type
mv index2.html index.html
and return and Ctrl-D. Type man at for more information on the "at" command.
posted by nicwolff at 10:37 PM on April 3, 2014 [4 favorites]
No that line only protects it if it's at the root. Feel free to memail or email if you have other questions. I'm at the end of my day but happy to help as much as you need tomorrow.
posted by artlung at 10:38 PM on April 3, 2014
posted by artlung at 10:38 PM on April 3, 2014
Do you really need to change the URL of the page (index.html to index2.html), or do you just need the content of the page to change? Because you could put both versions into index.html and use PHP or even javascript to switch to the new content at the appropriate time.
posted by FreezBoy at 3:41 AM on April 4, 2014 [1 favorite]
posted by FreezBoy at 3:41 AM on April 4, 2014 [1 favorite]
If you're not comfortable with the command line or linux or programming, probably the easiest way to do this is just to do it yourself at the appropriate time, instead of trying to script this.
posted by empath at 4:00 AM on April 4, 2014 [1 favorite]
posted by empath at 4:00 AM on April 4, 2014 [1 favorite]
At the time you need it changed just rename the files:
index.html -> index.old.html
index2.html -> index.html
posted by rabbitfufu at 5:46 AM on April 4, 2014
index.html -> index.old.html
index2.html -> index.html
posted by rabbitfufu at 5:46 AM on April 4, 2014
Looking at GoDaddy's documentation it looks like you don't need to use the command prompt/vi/write shell scripts.
Here is a how-to with screenshots.
I wouldn't mess with .htaccess files if I were you, just enter in the "mv index2.html index.html" command.
Regarding, keeping things hidden, GoDaddy should have a feature that allows you to turn off directory listing. Once you get directory listing turned off, just name your new index.html to something inscrutable (i.e. xN2908ediojus.slkjdflsk) and in all likelihood nobody will find it. (Your cron command would then be "mv xN2908ediojus.slkjdflsk index.html")
posted by baniak at 7:19 AM on April 4, 2014
Here is a how-to with screenshots.
I wouldn't mess with .htaccess files if I were you, just enter in the "mv index2.html index.html" command.
Regarding, keeping things hidden, GoDaddy should have a feature that allows you to turn off directory listing. Once you get directory listing turned off, just name your new index.html to something inscrutable (i.e. xN2908ediojus.slkjdflsk) and in all likelihood nobody will find it. (Your cron command would then be "mv xN2908ediojus.slkjdflsk index.html")
posted by baniak at 7:19 AM on April 4, 2014
Response by poster: Do you really need to change the URL of the page (index.html to index2.html), or do you just need the content of the page to change? Because you could put both versions into index.html and use PHP or even javascript to switch to the new content at the appropriate time.
It won't be possible to manually do the change at the time needed, and nosy parkers need to be avoided.
posted by feckless fecal fear mongering at 8:29 AM on April 4, 2014
It won't be possible to manually do the change at the time needed, and nosy parkers need to be avoided.
posted by feckless fecal fear mongering at 8:29 AM on April 4, 2014
The nosy parker issue is very easily disposed of, because there's no reason why your scheduled replacement for index.html needs to have an obvious name like new-index.html.
If the new page's name is a long randomly generated string of letters like bzkxl-opmyi-ccjow-qxnpv-yotfk.html, and nothing else links to it, and it's in a directory that has a real index.html so that the server won't spill the beans by faking up its own index page from a directory listing, then nobody but you will ever see it.
So really all you need to do is upload your new page to your site's default folder as qjjdx-vhspl-qdyjw-yoanu-cpbcx.html or similar, then schedule a task for whatever time you like to rename that to index.html. If you're willing to use command line tools for that, the bash commands you need would look like this:
The <<EOF stuff is a "here document" redirection, which causes everything after the <<EOF line and before the line containing EOF by itself to get fed into the standard input of the command with the <<EOF attached - in this case, the "at" command, which expects to be fed a block of script to be run at the scheduled time.
You can actually use any pattern you like instead of EOF, but EOF is conventional.
posted by flabdablet at 10:36 AM on April 4, 2014 [1 favorite]
If the new page's name is a long randomly generated string of letters like bzkxl-opmyi-ccjow-qxnpv-yotfk.html, and nothing else links to it, and it's in a directory that has a real index.html so that the server won't spill the beans by faking up its own index page from a directory listing, then nobody but you will ever see it.
So really all you need to do is upload your new page to your site's default folder as qjjdx-vhspl-qdyjw-yoanu-cpbcx.html or similar, then schedule a task for whatever time you like to rename that to index.html. If you're willing to use command line tools for that, the bash commands you need would look like this:
at 3am Thursday <<EOF mv -f -b qjjdx-vhspl-qdyjw-yoanu-cpbcx.html index.html EOFmv is pronounced "move", which is Unix for "rename"; the -f option means "force", which lets mv know it's OK to rename a new file over the top of an existing old file; and the -b option means "backup", so mv will automatically keep the old index.html around as index.html~ instead of stomping it completely.
The <<EOF stuff is a "here document" redirection, which causes everything after the <<EOF line and before the line containing EOF by itself to get fed into the standard input of the command with the <<EOF attached - in this case, the "at" command, which expects to be fed a block of script to be run at the scheduled time.
You can actually use any pattern you like instead of EOF, but EOF is conventional.
posted by flabdablet at 10:36 AM on April 4, 2014 [1 favorite]
« Older Do they have Art Nouveau-esque doormats? | My Google searches are being invaded by an email... Newer »
This thread is closed to new comments.
I'd put something like this in my crontab: And on 4/4 at 23:00 the new_index.html would replace the old index.html
Buth things could go wonky if your website/blog has some sort of caching or whatnot.
posted by zengargoyle at 8:25 PM on April 3, 2014 [1 favorite]