Wednesday, August 08, 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/ 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. and $Redirect_To_Domain should be the domain to which you are redirecting to (e.g.

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.


red | hongyi said...


Danny Ng said...

why chinese song...?! why...?!


red | hongyi said...

becoz u're going out with a chinese girl, that's why! :D

look forward to more david tao goodness!!!

Anonymous said...

why your script doesn't work in my server ?

Danny Ng said...

what exactly did you type in?

Caillou Spiele said...

it doesn't work for me :(

Project Playlist