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.

9 Comments on "redirecting in plesk"


  1. Thanks for the article Danny! Excuse my ignorance but what does it mean when you say

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

    Is that required to run the 301 redirect in Plesk for Windows? And if so, could you explain how to exactly configure those permissions. I’ve never heard of that type of command. I’m trying to redirect my http site to my new https. Your help would be much appreciated. Thank you.

    Reply

  2. Thanks Danny this post was a lifesaver. Have been banging my head at my desk trying to use Plesk. The .htaccess redirects works a treat. ;)

    All the best, Sahus

    Reply

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

    look forward to more david tao goodness!!!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *