Browsing articles tagged with " tutorial"
Aug 7, 2007

redirecting in plesk

I thought I’d make an entry here about important stuff which I might need to know later on. Kinda like building a knowledge base. Perhaps other people can benefit from this as well.

So I was informed on how to redirect traffic to another website on Plesk today at work. Pretty handy 4 line configuration to the .htaccess file.

First of all, change your working directory by running
>> cd /var/www/vhosts/$domain/httpdocs

Note: $domain is the name of the domain from which you are redirecting from (e.g. /var/www/vhosts/mywebsite.com.au/httpdocs). If you’re running from Plesk, just navigate to your httpdocs folder by going to the desired domain to redirect and clicking on File Manager.

Create a .htaccess file in that folder (if it doesn’t already exist). Then enter the following lines to the file,

RewriteEngine on
RewriteCond %{SERVER_NAME} $domain [OR]
RewriteCond %{SERVER_NAME} www.$domain
RewriteRule ^.*$ http://$Redirect_To_Domain [R=301]


Note: $domain match the $domain above (e.g. mywebsite.com.au) and $Redirect_To_Domain should be the domain to which you are redirecting to (e.g. mynewwebsite.com.au).

Once you have saved the file, you have to configure its permissions. You can run,
>> chmod 755 .htaccess

or if you’re in Plesk, just make sure the permissions are rwx r-x r-x (uncheck write access to Group and Others).

If your website accepts SSL connections, simply do the same for the folder httpsdocs.

Jul 24, 2007

JavaScript Inheritance

Found some really useful tutorials on how to use inheritance in JavaScript. This is pretty new to me as I haven’t learnt JavaScript formally but through the Internet. <3 Internet

Anyways, I’m working on an automated HTML generator using JavaScript since I don’t have access to server side stuff. Gosh it gets complicated doing it all on client side!

http://www.cs.rit.edu/~atk/JavaScript/manuals/jsobj/

http://www.webreference.com/js/column79/index.html

Jul 4, 2007

flip text


Some cool javascript I found on the web. Flips whatever text you give it upside-down and reversed!

Original:
Jan 17, 2007

Rendering table in IE using DOM

So I thought I’d share with people who would be interested in these sort of things (programming), especially dealing with JavaScript’s Document Object Model (DOM). I came across an annoying bug that has bugged me for the past few days which turned out to be quite simple.

First take a look at the following JavaScript:

var container = document.createElement(“div”);
var table = document.createElement(“table”);
var tr = document.createElement(“tr”);
var td = document.createElement(“td”);
var text = document.createTextNode(“This is a test.”);
td.appendChild(text);
tr.appendChild(td);
table.appendChild(tr);
container.appendChild(table);
document.body.appendChild(container);

When you go alert(container.innerHTML), you will see that the DOM is created correctly but for some reason it is not showing up. Even by inspecting the DOM using IE7’s add-on, IE Developer Toolbar, you will see that the DOM is constructed correctly. When running this on Firefox, the code seems to work the way you want it to. So what the heck is the problem?!?

Well after many hours of googling, I came across an article that helped me solve my problem. Apparently, a tbody element is required within the table tag which is interesting because according to the HTML4 Standard, a tbody isn’t required within a table. Adding a couple of lines will fix this rendering problem:

var table = document.createElement(“table”);
var tbody = document.createElement(“tbody”); <–
var container = document.createElement(“div”);
var tr = document.createElement(“tr”);
var td = document.createElement(“td”);
var text = document.createTextNode(“This is a test.”);
td.appendChild(text);
tr.appendChild(td);
tbody.appendChild(tr); <–
table.appendChild(tbody); <–
container.appendChild(table);
document.body.appendChild(container);

Hopefully you won’t spend as much time as me trying to figure out this problem.

Twitter Updates