HtmlRedirect Source


HtmlRedirect Source

See also: Redirect web page

#!/bin/bash
# htmlredirect - create static html redirect page to new url
 
 
if [ "" == "-h" ]; then
	cat << EOT
htmlredirect v0.2 - create static html redirect page to new url
(c) 2005 Tero Karvinen http://www.iki.fi/karvinen/
http://www.iki.fi/karvinen/htmlredirectpage/
 
Usage:
	htmlredirect [newurl]
	htmlredirect [old relative url] [newurl]
ChangeLog:
	2005-11-19t0903 Created
 
EOT
	exit 0;
fi
 
if [ -z "" ]; then
	echo "Use -h for help.";
	exit 1;
fi
 
 
OPWD=`pwd`;
 
if [ -z "" ]; then
	NEWURL="";
else
	DIR=$1;
	NEWURL="";
	if [ -e "$DIR" ]; then
		echo "Allready exists folder $DIR. Exiting. ";
		exit 2;
	else
		mkdir $DIR && echo "Created directory $DIR.";
		cd $DIR;
	fi
fi
 
if [ -e "index.html" ]; then
	echo "Allready exists index.html. Exiting.";
	exit 2;
fi
 
cat << EOT > index.html
<?xml version="1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN"
 "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Moved...</title>
    <meta http-equiv="Content-type" content="text/html; charset=UTF-8" />
    <link rel="prefetch" href="http://www.iki.fi/karvinen" />
    <meta http-equiv="Refresh" content="3; url=http://www.iki.fi/karvinen" />
</head>
<body>
<h1>Moved...</h1>
<!-- Created with htmlredirect by Tero Karvinen, see www.iki.fi/karvinen -->
<p>Moved to <a href="http://www.iki.fi/karvinen">http://www.iki.fi/karvinen</a>. You
will be automacally redirected in 3 seconds. </p>
</body>
</html>
EOT
 
perl -p -i -e "s|http://www.iki.fi/karvinen|$NEWURL|g" index.html;
 
cd $OPWD;
 


Posted in Old Site | Tagged | Comments Off on HtmlRedirect Source

Comments are closed.