1

I have osclass website at openshift free tier.but for openshift only www version of domain is working not root.My site htaccess file have follow content. what i add to .htaccess file so that it automatically redirect user from http;//mydomain.com to www.mydomain.com

<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule>

GiLL
  • 354
  • 1
  • 5
  • 15

1 Answers1

1

Add this rule just below RewriteBase / line:

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • is this right RewriteEngine On RewriteBase /RewriteCond %{HTTP_HOST} !^www\. [NC] RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [NE,R=301,L] RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] – GiLL Mar 05 '14 at 14:22
  • anubhava i add mydomain.com and www.mydomain.com alias at openshift server is it is working.i am little bit scared while editing .htaccess file any suggestion for backup the osclass .htaccess file – GiLL Mar 05 '14 at 14:30