Web Projects Consulting

Non-www to www Redirect on Plesk Hosting

Plesk hosting offers you an option of “Use a single directory for housing SSL and non-SSL content”. Using it is sometimes bring in some problems when people type in the url starting with www and some ajax scripts are tuned to work without it and visa versa. As a result, ajax works with errors. Noramlly, I would want my server to serve only www.SOME_DOMAIN.com.  To fix it, I would tune the .htaccess file the simplest code possible (mod_rewrite should be abvailable which is regular for Plesk installation):

RewriteEngine on

RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTP_HOST} ^SOME_DOMAIN\.com
RewriteRule ^(.*)$ http://www.SOME_DOMAIN.com/$1 [R,L]

RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_HOST} ^SOME_DOMAIN\.com
RewriteRule ^(.*)$ https://www.SOME_DOMAIN.com/$1 [R,L]

 

 

Leave a Reply

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


This site uses Akismet to reduce spam. Learn how your comment data is processed.